0

I was following this Checking Ram size article for my cloud foundry Java app running on Ubuntu LTS 14.04. From what I understand the physical memory of the instance running my Java process is 32g. For the Java app I specified the heap size as 1g. When I look at the output of top command, I see that it has 3,221,372 KiB which is 3g.

Is there a logical explanation of

  • Why Java process is using 3g virt memory when there is adequate physical memory and

  • Why Java process is using more memory than 1g, I specified?

Result of grep MemTotal /proc/meminfo | awk '{print $2 / 1024}'

32170.2

Result of top command output:

Tasks:   5 total,   1 running,   4 sleeping,   0 stopped,   0 zombie
%Cpu(s): 46.2 us, 43.2 sy,  0.0 ni,  1.7 id,  0.3 wa,  0.0 hi,  8.5 si,  0.2 st
KiB Mem:  32942284 total, 27706852 used,  5235432 free,   357028 buffers
KiB Swap: 32949308 total,  2546016 used, 30403292 free.  6546428 cached Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                  
      7 vcap      10 -10 3221372 108524  11936 S   1.7  0.3   1:31.17 java               

Result of free -g

             total       used       free     shared    buffers     cached
Mem:            31         26          4          0          0          6
-/+ buffers/cache:         19         11
Swap:           31          2         28
  • With regards to your first question, it may be due to your system's [swappiness](https://help.ubuntu.com/community/SwapFaq). Just because some RAM is available doesn't mean your system won't start using swap. And it is your system that decides, not Java. For the second, what is your stack size? – Andrew Shum Nov 30 '17 at 21:48
  • How do I check the stack size? – randominstanceOfLivingThing Nov 30 '17 at 22:18
  • Did some googling and after running the command `ulimit -s`, result came in a "8192". – randominstanceOfLivingThing Nov 30 '17 at 22:26
  • In that case, I am not sure regarding your second question. However, I still stand by my reply regarding the first one; especially if you haven't changed your systems swappiness from the default value. – Andrew Shum Nov 30 '17 at 22:40

0 Answers0