Instructing the JVM to run the major garbage collection by command?

2
Currently I'm monitoring an application that gradually consumes a lot of memory in the tenured generation space over a period of time. Now I'm – Regardless of the fact that JVM runs the major garbage collection when a certain percentage is reached – wondering if it’s possible to instruct the JVM to run the major garbage collection by command? This way I could analyze if the GC will reduce the tenured generation (to zero).
asked
5 answers
1

Hi Alfie!

The garbage collector in any Java application is automatic and I'm pretty sure it cannot be instructed or triggered through a specific command.

Do you have an idea on what could cause the build up that's clearly visible in your chart? What caused the three dips? The JVM apparently has a reason to keep certain things in memory. Finding out what that reason is and removing it (if this of course doesn't break anything) is probably the way to go here.

Good luck!

 

answered
1

You can use jconsole.exe which offers the button “Perform GC” on its memory tab. This calls System.gc() which gently suggests that the Garbage Collector will run. As Wiemer already stated, there is no guarantee that the GC will run. You’ll find jconsole.exe in your AdoptOpenJDK installation path in the bin directory.

answered
1

I wonder if using a tool like APD or AQM would help show what’s happening in your application to use that much memory.

https://docs.mendix.com/addons/apd-addon/
https://docs.mendix.com/addons/aqm-addon/

answered
1

If you’re eager to investigate this, there are hardcore methods to do so. Try dumping the heap memory space and analyzing it.

https://www.baeldung.com/java-heap-dump-capture

AQM does static code analysis. So it’s not useful in this case since it’s a runtime behavior issue. APD on the other hand could help.

answered
-17

https://mlsdev.com/blog/healthcare-mobile-app-development is a leading app software development company with a variety of services to help you succeed with your business. They can help you develop a mobile application that works for your audience. You'll never regret hiring an app software development company. They will ensure that your project is launched and maintained properly. And their teams will continue to support it for you long after it's released, which is very important. A great app developer can be a major asset to your business.

answered