Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java native memory usage

Is there any tool to know how many native memory has been used from my java application ? I've experienced outofmemory from my application : Current setting is : -Xmx900m

Computer, Windows 2003 Server 32bit, RAM 4GB.

Also is changing boot.ini to /3GB on windows, will make any difference? If is set Xmx900m, how much max native memory can be allocated for this process ? is it 1100m ?

like image 747
NoodleX Avatar asked May 03 '10 07:05

NoodleX


People also ask

What is Java native memory?

Native memory is the memory provided to the application process by the operating system. The memory is used for heap storage and other purposes. The native memory information available in the native memory perspective view varies by platform but typically includes the following information: Table 1.

How do I check my native memory usage?

Get summary data: To get a summary view of native memory usage, start the JVM with command line option: -XX:NativeMemoryTracking=summary . Example 2-2 is a sample output that describes NMT for track level set to summary. One way to get this sample output is to run: jcmd <pid> VM. native_memory summary .

How much RAM can a Java program use?

-Xmx size in bytes Sets the maximum size to which the Java heap can grow. The default size is 64M. (The -server flag increases the default size to 128M.) The maximum heap limit is about 2 GB (2048MB).

How much RAM is used by JVM?

This resource memory used by the JVM is often called overhead. The recommended minimum starting memory point for 64-bit Maximo 7.5 JVMs systems is 3584 MB. Therefore we recommended that physical memory availability for each JVM be 4096 MB;0.5 GB is for JVM allocation and 512 MB is for overhead.


2 Answers

This article gives some good information about hunting down native memory issues and explains how you run out of native memory.

like image 75
11101101b Avatar answered Oct 24 '22 09:10

11101101b


(in my case I use java 8)

add to command line: -XX:NativeMemoryTracking=summary

then launch jcmd <PID> VM.native_memory

You should get something like this:

Total: reserved=3863657KB, committed=1679977KB
-                 Java Heap (reserved=1843200KB, committed=824320KB)
                            (mmap: reserved=1843200KB, committed=824320KB) 

-                     Class (reserved=1311974KB, committed=298726KB)
                            (classes #52579)
                            (malloc=5350KB #76340) 
                            (mmap: reserved=1306624KB, committed=293376KB) 

-                    Thread (reserved=263278KB, committed=263278KB)
                            (thread #256)
                            (stack: reserved=262140KB, committed=262140KB)
                            (malloc=839KB #1280) 
                            (arena=299KB #510)

-                      Code (reserved=278521KB, committed=164773KB)
                            (malloc=28921KB #37983) 
                            (mmap: reserved=249600KB, committed=135852KB) 

-                        GC (reserved=114897KB, committed=77093KB)
                            (malloc=13729KB #67925) 
                            (mmap: reserved=101168KB, committed=63364KB) 

-                  Compiler (reserved=461KB, committed=461KB)
                            (malloc=330KB #1138) 
                            (arena=131KB #3)

-                  Internal (reserved=13877KB, committed=13877KB)
                            (malloc=13845KB #72978) 
                            (mmap: reserved=32KB, committed=32KB) 

-                    Symbol (reserved=28871KB, committed=28871KB)
                            (malloc=24740KB #275452) 
                            (arena=4131KB #1)

-    Native Memory Tracking (reserved=8393KB, committed=8393KB)
                            (malloc=45KB #523) 
                            (tracking overhead=8348KB)

-               Arena Chunk (reserved=184KB, committed=184KB)
                            (malloc=184KB) 

For more information see https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html

like image 20
Eugene To Avatar answered Oct 24 '22 10:10

Eugene To