开发者

How can I optimize the memory usage of JVM?

开发者 https://www.devze.com 2023-03-10 02:21 出处:网络
I would like to ask if anyone here knows a way how to optimize the memory usage of the JVM? We are using a java service wrapper (YAJSW) that invokes the JVM and the physical memory usage is around 40M

I would like to ask if anyone here knows a way how to optimize the memory usage of the JVM? We are using a java service wrapper (YAJSW) that invokes the JVM and the physical memory usage is around 40MB. I want to lessen this to let's say 5-10MB. How do I achieve this?

So far, I only have the following configuration:

java =-Xmx1024m

I have 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 made no difference at all. What would be the correct configuration settings for this? or, what else do i have to do to optimize this?

Thank in advance for your answers.


Are you talking about resident memory or virtual? On my machine, a simple while(true); in main without anything else already gets me 10 MB of resident memory, mostly because of memory mapped r/o libraries (libc, libm, librt, libpthread...) and jars. Reducing, if possible at all, the memory footprint any further, or to 10 MB in any non-trivial application, would only mean more paging, thus reducing speed.

Virtual memory, on the other hand, is 1.1 GB on my machine, which could be reduced if necessary, but why do so? Unused virtual memory doesn't really cost anything.

Edit: Apart from that, you may want to have a look at the other HotSpot VM Options, especially MaxHeapFreeRatio.


The documentation for YAJSW states:

Wrapper memory requirements
The flexibility of YAJSW comes at a price. Using java for the wrapper process has many advantages. However we pay the java price of higher memory footprint. Whereas the JSW wrapper requires only a few k of memory, the minimal virtual memory requirement of YAJSW is 90 MB and 40 MB physical memory. The value varies depending on the OS and the functions.

If your application can run within 32bit memory restrictions you can use the community edition of Tanuki as it has a lower footprint.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号