0

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?

Santron Manibharathi
  • 628
  • 5
  • 12
  • 26

2 Answers2

3

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

Community
  • 1
  • 1
Angelo Fuchs
  • 9,825
  • 1
  • 35
  • 72
  • Is there any way to check what is being held inside the java.exe process' memory? I have set max heap size to 3MB, Stack size to 128k, But the memory used by java.exe is around 10MB. How can i check what is there? – Santron Manibharathi May 22 '13 at 12:33
  • @SantronManibharathi You have to use a profiler. Use that keyword and read the documentation for it. Its not that hard, but it will take its time until you understand what you see there. – Angelo Fuchs May 22 '13 at 12:50
0

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.

Paweł Adamski
  • 3,285
  • 2
  • 28
  • 48