How to shrink the JVM heap size during runtime...
843811Jun 4 2005 — edited Jun 6 2005Hi All,
I have a problem associated with JVM heap size. In my application program, I am reading the file and passing it to the other process through the stream. The size of the file may vary and may go up to 01 GB. What problem I am facing is that once I supplied the file of big size, the heap expands itself and it read the file and passes it to the stream. After completing the job, the JVM heap is not shrinking. So when I continuously reading the big files, it stops reading the files as heap size maxMemory() equals to totalMemory(). But if I restart my program it reads the file (as JVM reinitializes its heap size). I am setting the JVM heap size maximum up to 512 MB.
Is there any runtime method to shrink the heap size after processing? Even Runtime.getRuntime.gc() is not helping. It is freeing the memory but the heap size is not shrinking.
Any help is appreciating.
Thanks in advance.
Regards
Ashish