Hi all,
I have an application built on Flex at front-end, spring-hibernate at back-end. I have a memory issue when client sends any request to the back-end. I saw the memory used by tomcat in taskmanager keep increasing even when the session factory is closed. Investigating into the log of the application, I saw all the beans in my application be created whenever client sends request to back-end. The beans in my application have the scope as quot;singletonquot;.
I put in some methods the command to force the garbage collection happen such as quot;Runtime r = Runtime.getRuntime();r.gc()quot;. If I print out the free memory before and after method call, I saw the free memory at after-call go back up, but the memory used in taskmanager by tomcat does not go down.
Can anyone give me a suggestion?
Best,
Java runs as an operating system process. It obtains a certain amount of memory from the OS to do its work. This is what you see in Task Manager. Inside the JVM, Java uses much of the memory it got from the OS in an internal memory heap that it manages itself, keeping lists of free and used memory. This is the view you get from the Java Runtime object.
When Java executes a garbage collection cycle, all it does is change some of its internally managed memory blocks from quot;usedquot; to quot;freequot;. This transformation will not be detected in the OS view of the process (in Task Manager). Quite often you will not see the OS view of used memory increase or decrease (after the application has finished initializing and reached a stable state), even while lots of allocations and collections are going on in the JVM. |