5

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.

fleur
  • 115
  • 1
  • 12
  • figures you provide are a bit weird... You say you want to downsize the memory usage to 5-10 MB, and you set it to a lot more (1G for heap, 256M for PermSize). – Grooveek Jun 01 '11 at 08:08
  • I really don't have any idea on the correct parameters to use. If I lessen the heap size, the application being wrapped by the service may be affected. Anyway, are you suggesting that I lessen the heap size and PermSize? what is the tolerable value for these? (512 for heap, 64 for PermSize?) – fleur Jun 01 '11 at 08:26
  • I don't see how any of the provided options should influence the minimum memory usage? I'd try stuff like -XX:+UseCompressedStrings or -XX:+UseCompressedOops (on 64bit VMs) - well actually I'd hope you're using a 32bit VM if memory is important so the 2nd one shouldn't help. – Voo Jun 01 '11 at 19:50
  • @Voo: I'm actually using 64bit VM. I tried to use the -XX:+UseCompressedStrings but – fleur Jun 02 '11 at 04:25
  • ..but it did not make any difference, too. – fleur Jun 02 '11 at 04:54

2 Answers2

1

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.

  • Yes, I'm talking about the resident memory. I tried the MaxHeapFreeRatio, so far, I have not seen any difference at all. But, thanks for the link :) – fleur Jun 02 '11 at 04:07
  • If you care about resident memory usage of 10MB, does it mean you run lot of app instances concurrently? If yes, maybe, you should consider switching to one application constantly in memory which serves lot of clients? – Victor Sorokin Jun 18 '13 at 15:06
0

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.

opticyclic
  • 7,412
  • 12
  • 81
  • 155