The memory usage of the Java process is much more than what Runtime.totalMemory and other methods say.

I have long been stuck in this problem without any hint. Would really appreciate if someone could help.

I am running a Java application on a device with an ARM v7 processor. Ubuntu is installed on it. Memory usage when browsing using the "top" or "free -m" commands is about 180 MB, which is much more than the methods Runtime.freeMemory and others tell me.

This is how I start my application:

java -Xcheck: jni -XX: MaxPermSize = 25m -Xmx65m -XX: ReservedCodeCacheSize = 10m -jar MyAPP.jar myconfig.xml

As I understand it, the total memory usage of this process should not cross 25 + 65 + 10 = 100 MB. It could be a little bigger (other heap-free spaces that I don't know about). But even then I do not think that the difference should be like that (80 MB).

This is what the β€œRuntime” commands seem to tell me in my logs (I use these commands to print usage information as part of my debug logs).

Usage Information: Avaialable processor: 2 Free memory for JVM: 8474344, Current memory: 5943576, Maximum JVM memory allowed to use: 66977792

Exit from the "top":

PID   USER     PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
3926  linaro   20  0   266m  188m 3636 S  1.0 21.1   0:37.81 java

Exiting "free -m":

When starting the Java process:

        total       used       free     shared    buffers     cached
Mem:     893         842         51          0         40        216
-/+ buffers/cache:   585        308
Swap:     0          0          0

When the process is stopped:

         total      used       free     shared    buffers     cached
Mem:      893        656        237          0         40        216
-/+ buffers/cache:   400        493
Swap:      0          0          0

, 493 - 308 = 185, , "top" ( , , , ).

, "" 14 - 20 . , , Runtime. , -, , 180 .

, , (MacBook Pro) Linux Linux ( ARM), . 60 , .

, , , Java VM, ARM, Java SE Embedded Oracle.

, . , : -).

UPDATE:

Java, , (JNI). , . sqlite-jdbc . , 24 !!! , - jdbc sqlite, , . , .

-Sandeep

+3
1

, , - JVM Process Memory.

:

Vs - JVM

JVM Process vs JVM

JVM , .

+1