2
votes

I'm trying to understand the usage of virtual memory for my java application, which seems to depend on the environment i'm running my jar.

I have two environments:

env 1

cat /proc/version
Linux version 3.5.0-48-generic (buildd@roseapple) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #72~precise1-Ubuntu SMP Tue Mar 11 20:08:23 UTC 2014

java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
OpenJDK Server VM (build 24.45-b08, mixed mode)

env 2

cat /proc/version
Linux version 3.2.0-49-generic (buildd@komainu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #75-Ubuntu SMP Tue Jun 18 17:39:32 UTC 2013

java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

command:

java -Xms128m -Xmx256m -cp myjar.jar com.test.Main

I run the exact same jar, same command in both environments and the virtual memory usage differs greatly.

On env 1 it all works as I think it should, reserving up to 600Mb in virtual memory (Heap xmx256m + permGen + other little things). However on env 2 virtual memory goes up to 2600Mb.

physical memory usage on both environments seems fine and equal to configured sizes.

I think virtual memory should be as in env 1, but I can't find a explanation for env 2 to use that much.

Anyone have experienced this? What should I look for in the evironment or in the java configuration?

1
Virtual memory usage is not a function of your Java application. It's dependent on a whole host of other factors, especially the way your operating system is configured..Robert Harvey
The answer about 32-bit and 64-bit is correct. check stackoverflow.com/a/28935176/166062 as well.Lari Hotari

1 Answers

0
votes

Looks like env2 runs 64-bit Java (OpenJDK 64-Bit Server VM) while env1 Java is 32-bit.

Check /proc/PID/smaps - it gives the full map of process virtual address space.