I have a complex java application running on a large dataset. The application performs reasonably fast but as time goes it seems to eat lots of memory and slow down. Is there a way to run the JVM garbage collector without re-starting the application?
I have a complex java application running on a large dataset. The application performs
Share
No, You cant force garbage collection.
Even using
You can just make a request for garbage collection but it depends on JVM to do it or not.
Also Garbage collector are smart enough to collect unused memory when required so instead of forcing garbage collection you should check if you are handling objects in a wrong way.
If you are handling objects in a wrong way (like keeping reference to unnecessary objects) there is hardly anything JVM can do to free the memory.
From Doc
Open Bug regarding
System.gc()documentationFew useful link to visit when you think you should force JVM to free up some memory
All says
System.gc()dont guarantee it.