Reputation: 642
I have a java program in which i do quite more number of operations on an object of a class. The Object is created inside a for loop which runs a finite number of time. Once the loop is completed, i call System.gc() to clear the used space in Heap. But the process java.exe in task manager still uses more RAM. Is there any way to find what is stored inside the process? Or Is there any method to perform a dump and compare it in a readable form?
Upvotes: 0
Views: 180
Reputation: 3415
Try to use Java profiler (e.g. jvisualvm which is delivered with JDK). You can connect to running application and check what lies on heap.
Upvotes: 0
Reputation: 9941
Your java.exe
won't free memory it has once allocated. The garbage collection just frees it for the other processes INSIDE your java program.
If this topic is interesting to you, you should read some documentation about memory handling inside Java. Its too complex to be answered appropriately here.
Have a look here for some pointers: https://softwareengineering.stackexchange.com/questions/176880/which-part-of-the-memory-is-used-for-the-garbage-collector
Upvotes: 3