...but it will not reclaim the set of student's memory. Obviously it is a memory leak
Tom Reilly wrote:
...but it will not reclaim the set of student's memory. Obviously it is a memory leak
Why do you think there is a memory leak?
Henry Wong wrote:
Tom Reilly wrote:
...but it will not reclaim the set of student's memory. Obviously it is a memory leak
Why do you think there is a memory leak?
Agreed. I don't see a memory leak either.
Henry
OCPJP 6, IBM DB2, IBM RAD Certified
http://javawithsachin.blogspot.in/
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Edward Chen wrote:
A course has lots of students, when course is gone, then all students should be gone, too. (let us assume this is right, please don't argue this). We delete course, set the course to null, then we should set all students inside to null, this way will let GC reclaim course and its students memory.
Henry Wong wrote:The GC determines whether an instance should be collected by reachability. Simply, if it is not reachable, it will be collected.
Edward Chen wrote:
Then, how the GC knows if an object is reachable ? Can we write a program to prove it ?
Edward Chen wrote:
If that studentSet is static, then when GC will reclaim its memory ?
Henry Wong wrote:
Depends on the collector. The new collector is a copy collector. Instances gets moved from one side of the heap to the other, as the GC traverse the objects from the roots. Whatever is left over is not reachable.
The tenured collector is a mark and sweep collector. Instances get marked as the GC traverse the objects from the roots. Whatever is left over will be collected during the sweep phase. The sweep process also compacts the heap.
Edward Chen wrote:
Not fully understand this. For copy collector, do you mean, copy all reachable objects to one side of the heap ? but it will cost a lot when moving an object .
Edward Chen wrote:
For mark and sweep collector, how sweep process handles memory fragmentation ?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |