Difference in committed memory and RSS in java process

前端 未结 1 1779
栀梦
栀梦 2020-12-30 12:10

I am running a simple java process running jetty, for which top shows 2.9g of RAM. JDK version used is 1.8.0_112.

Using Native Memory Tracking (jcmd), it is

相关标签:
1条回答
  • 2020-12-30 12:52

    pmap -X <pid> will show the detailed breakdown of RSS from OS perspective.

    NMT does not count memory allocated by native non-JVM code, even if this memory is allocated by the standard Java Class Library, e.g. by native methods of ZipInputStream. See the related question.

    The other possible reason is malloc itself. Native memory allocator rarely returns unused memory back to the OS. For example, if an application allocates 1 GB in small chunks with malloc and then frees all these chunks, from the application perspective there will be 1 GB of free memory, but OS is likely to count this 1 GB in RSS. This memory basically belongs to the application's malloc pool and can be reused for future malloc calls.

    Try to use alternative allocators like jemalloc or tcmalloc. By the way, they both have an allocation profiler that may help in finding native memory leaks.

    0 讨论(0)
提交回复
热议问题