How to optimize JVM memory usage?

I would like to ask if anyone knows how to optimize JVM memory usage? We use the java service shell (YAJSW), which calls the JVM, and the physical memory usage is about 40 MB. I want to reduce this to say 5-10 MB. How to achieve this?

So far I only have the following configuration:

java =-Xmx1024m

I also tried this:

java =-Xms1024m -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=2 -XX:PermSize=256m -XX:MaxPermSize=256m

But these configuration settings have not changed at all. What will be the correct configuration settings for this? or what else do i need to do to optimize this?

Thanks in advance for your answers.

+4
source share
2 answers

Are you talking about resident memory or virtual? On my machine, a simple while(true); in main without anything else, it already receives 10 MB of resident memory, mainly due to bibliographic memory libraries (libc, libm, librt, libpthread ...) and cans. Reducing, if possible at all, the amount of memory anywhere or up to 10 MB in any non-trivial application would mean only more swap, which would decrease the speed.

On the other hand, the virtual memory is 1.1 GB on my machine, which can be reduced if necessary, but why do this? Unused virtual memory costs nothing.

Edit: Also, you might want to take a look at the other "HotSpot VM Options" , especially MaxHeapFreeRatio.

+1
source

The documentation for YAJSW reads:

Wrapper Memory Requirements
YAJSW flexibility comes at a price. Using java for the wrapper process has many advantages. However, we pay the price of java with higher memory capacity. While the JSW wrapper only requires a few k memory, the minimum need for YAJSW virtual memory is 90 MB and 40 MB of physical memory. The value depends on the OS and features.

If your application can run within 32-bit memory limits, you can use the Tanuki community version as it has a lower footprint.

0
source

All Articles