Hi, Is there any way to reduce the memory footprint of a full blown JVM. I am trying to launch a Java application and keep it running for a long time and would love to make it lean in terms of footprint. I have tried to do some research, but unfortunately couldn't gather anything useful. It would be great if someone could share some pointers or experiences.
Since so much of the memory footprint of a running jvm is due to loaded classes, it seems to me that the first line of defense would be using as few classes as possible. JVMs for reallllly small environment that I have looked at have left out long and double math functions to reduce the core code.
a) reducing the amount of free heap space, for example using the following start up parameters:
This means that the JVM will keep the heap at a size so that 10-20% of the heap will be free. The default values are 40-70%. You might want to test the impact on the performance of the garbage collector when you do this.
b) reducing the size of the permanent generation
Default is 64 MB - a too low value will lead to an OutOfMemoryError: permgen
c) reducing the size of the hot spot engine's code cache:
Default is 32 MB - a too low value will result in lost performance.
Since Java 5, you can use the JConsole to see how much of the available space is actually used by your application.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by William Brogden: Since so much of the memory footprint of a running jvm is due to loaded classes, it seems to me that the first line of defense would be using as few classes as possible.
The effect of directly using one more class can vary greatly. If that class has no dependencies on other yet-unloaded classes, the effect will be small. If that class depends on whole frameworks that are not yet loaded, huge amounts of memory will be used. For instance, as soon as you use any Swing class, loads of other classes will get loaded.
There's an option on the JVM to report information about loaded classes. I forget what it is, but it could be very useful here - look it up.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop