On clicking garbage collection tab in profiling, it will really do garbage collection or its optional? I know when we call system.gc() it not assured it will call garbage collection.
Asked
Active
Viewed 191 times
1 Answers
0
As per SCJP6 Chapter 3: Assignments
When Does the Garbage Collector Run?
The garbage collector is under the control of the JVM. The JVM decides when to run the garbage collector. From within your Java program you can ask the JVM to run the garbage collector, but there are no guarantees, under any circumstances, that the JVM will comply. Left to its own devices, the JVM will typically run the garbage collector when it senses that memory is running low. Experience indicates that when your Java program makes a request for garbage collection, the JVM will usually grant your request in short order, but there are no guarantees. Just when you think you can count on it, the JVM will decide to ignore your request.

Fritz
- 1,144
- 1
- 13
- 21