Does making an object reference null
, releases a memory occupied by that object.
For example:
public static void main(String[] args) {
ArrayList<Billing_productModel> list = new ArrayList<>();
for(int i=0;i<100;i++){
list.add(new BillingProductModel());
}
System.out.println("Size of List : "+list.size());
list = null;
while(true);
}
Here I have created an Arraylist
and added 100 new objects to it.
If I make object reference (list) null
, does Garbage Collecter clears a memory allocated to list.