views:

361

answers:

3

When running the same java process (a jar) under Windows and Linux (Debian) the Linux proces uses a lot more (12MB vs 36 MB), just from starting up. Even when trying to limit the heap size with -Xmx/Xms/etc, it stays the same. Nothing I try seems to help and the process always takes 36 MB. What explains this difference between Linux and Windows and how can I reduce the memory usage?

EDIT: I measure memory with the windows task manager and Linux top command. The JVM are the same and they are both 32-bit systems.

+2  A: 

I recommend using a profiler such as VisualVM to get a more granular view on what's going on.

Joonas Pulakka
A: 

One question I would ask to help me understand the problem better is :

Does my Java application's memory profile look dramatically different on the two platforms? You can answer this by running with -loggc and viewing the output in a gc visualizer like HPjmeter. You should try to look at a sample set with a statistically significant amount of data, perhaps 1000 or 10000 gc plots. If the answer is no, I would be tempted to attribute the difference you see to the JVM heap allocation requirements for start up. As 'nos' pointed out, pinpointing the difference can be notoriously hard. When you specified the -Xmx value on Linux, did the memory utilization exceed your Xmx value?

Amir Afghani
A: 

It is probably measuring the shared memory as well

BlueRaja - Danny Pflughoeft