I'm processing 20GB of data inside an XML and I'm using Spring Batch to accomplish that.
I mapped my XML with Jaxb2Marshaller.
This is my JAXB:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BILLSClass", propOrder = {
"bill"
})
@XmlRootElement(name="BILLS", namespace = "http://www.amdocs.com/amdd/stp/GBF")
public class BILLSClass {
@XmlElement(name = "BILL")
protected List<BILLClass> bill;
public List<BILLClass> getBILL() {
if (bill == null) {
bill = new ArrayList<BILLClass>();
}
return this.bill;
}
}
And this BILL have many objects inside. Approximately each BILL has almost 1GB of data.
Well, I'm processing this huge XML in this way
public void processXML(BILLSClass billsClass){
Iterator<BILLClass> iterator = billsClass.getBILL().iterator();
while (iterator.hasNext()) {
BILLClass bill = iterator.next();
processBill(bill);
billsClass.getBILL().remove(bill);
}
}
Notice that after I call processBill(bill)
inside the while, I remove the bill object I have just processed out of the billClass.
I want to know if the billsClass.getBILL().remove(bill)
will decrease the memory usage in the process or do I have to do something else in order to reduce the consumption of memory.
question from:
https://stackoverflow.com/questions/65851079/does-list-remove-or-list-removeall-free-memory-usage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…