Skip to content

Why is the memory reported by jeprof significantly less than what top shows for RSS? #2803

Open

Description

@twoholes

The process startup command is as follows:

MALLOC_CONF=prof:true,prof_leak:true,lg_prof_sample:30,lg_prof_interval:30,dirty_decay_ms:0,muzzy_decay_ms:0,stats_print:true,prof_prefix:/data/test/output/jeprof LD_PRELOAD=/data/test/libjemalloc.so.2 XXX
According to the top command, the RSS is 3.7G, while the memory reported by jeprof is only 768M.

jeporf info:
(jeprof) top
Total: 768.0 MB
384.0 50.0% 50.0% 384.0 50.0% rocksdb::BlockFetcher::ReadBlock
256.0 33.3% 83.3% 256.0 33.3% std::string::_Rep::_S_create
128.0 16.7% 100.0% 128.0 16.7% rocksdb::BlockFetcher::GetBlockContents
0.0 0.0% 100.0% 128.0 16.7% Server::GetInfo
0.0 0.0% 100.0% 128.0 16.7% Server::GetRocksDBInfo [clone .constprop.0]
0.0 0.0% 100.0% 640.0 83.3% __clone
0.0 0.0% 100.0% 128.0 16.7% __gnu_cxx::__to_xstring [clone .constprop.0]
0.0 0.0% 100.0% 128.0 16.7% __libc_csu_init
0.0 0.0% 100.0% 128.0 16.7% __libc_start_main
0.0 0.0% 100.0% 128.0 16.7% __static_initialization_and_destruction_0 [clone .constprop.0]

Using the pmap -x pid command, it shows that the main memory is in an anonymous segment:

00000000013b1000 264 212 212 rw--- [ anon ]
00007fe16b400000 241664 13188 13188 rw--- [ anon ]
00007fe17a100000 920576 99772 99772 rw--- [ anon ]
00007fe1b25ff000 4 0 0 ----- [ anon ]
00007fe1b2600000 8192 2048 2048 rw--- [ anon ]
00007fe1b2e00000 6674432 1523420 1523420 rw--- [ anon ]
00007fe34a500000 1156096 408844 408844 rw--- [ anon ]
00007fe390f00000 334848 280540 280540 rw--- [ anon ]
00007fe3a5700000 433152 215028 215028 rw--- [ anon ]
00007fe3bfe80000 341504 219264 219264 rw--- [ anon ]
00007fe3d4d00000 78848 14428 14428 rw--- [ anon ]
00007fe3d9b00000 121856 31724 31724 rw--- [ anon ]
00007fe3e1300000 867328 380936 380936 rw--- [ anon ]
00007fe416300000 500736 359788 359788 rw--- [ anon ]
00007fe434d00000 416768 251028 251028 rw--- [ anon ]
00007fe44e5ff000 4 0 0 ----- [ anon ]
00007fe44e600000 8192 2048 2048 rw--- [ anon ]
00007fe44ee00000 16384 16344 16344 rw--- [ anon ]
00007fe44ffff000 4 0 0 ----- [ anon ]
00007fe450000000 8192 2048 2048 rw--- [ anon ]
00007fe450800000 8192 8092 8092 rw--- [ anon ]
00007fe4511e9000 4 0 0 ----- [ anon ]
00007fe4511ea000 8192 44 44 rw--- [ anon ]
00007fe4519ea000 4 0 0 ----- [ anon ]
00007fe4519eb000 8192 44 44 rw--- [ anon ]
00007fe4521eb000 4 0 0 ----- [ anon ]
00007fe4521ec000 8192 44 44 rw--- [ anon ]
00007fe4529ec000 4 0 0 ----- [ anon ]
00007fe4529ed000 8192 92 92 rw--- [ anon ]
00007fe4531ed000 4 0 0 ----- [ anon ]
00007fe4531ee000 8192 88 88 rw--- [ anon ]
00007fe4539ee000 4 0 0 ----- [ anon ]
00007fe4539ef000 8192 92 92 rw--- [ anon ]
00007fe4541ef000 4 0 0 ----- [ anon ]
00007fe4541f0000 8192 88 88 rw--- [ anon ]
00007fe4549f0000 4 0 0 ----- [ anon ]
00007fe4549f1000 8192 92 92 rw--- [ anon ]
00007fe4551f1000 4 0 0 ----- [ anon ]
00007fe4551f2000 8192 52 52 rw--- [ anon ]
00007fe4559f2000 4 0 0 ----- [ anon ]
00007fe4559f3000 8192 40 40 rw--- [ anon ]
00007fe4561f3000 4 0 0 ----- [ anon ]
00007fe4561f4000 8192 40 40 rw--- [ anon ]
00007fe4569f4000 4 0 0 ----- [ anon ]
00007fe4569f5000 8192 92 92 rw--- [ anon ]
00007fe4571f5000 4 0 0 ----- [ anon ]
00007fe4571f6000 8192 92 92 rw--- [ anon ]
00007fe4579f6000 4 0 0 ----- [ anon ]
00007fe4579f7000 8192 96 96 rw--- [ anon ]
00007fe4581f7000 4 0 0 ----- [ anon ]
00007fe4581f8000 8192 92 92 rw--- [ anon ]
00007fe4589f8000 4 0 0 ----- [ anon ]
00007fe4589f9000 8192 44 44 rw--- [ anon ]
00007fe4591f9000 4 0 0 ----- [ anon ]
00007fe4591fa000 8192 92 92 rw--- [ anon ]
00007fe4599fa000 4 0 0 ----- [ anon ]
00007fe4599fb000 8192 92 92 rw--- [ anon ]
00007fe45a1fb000 4 0 0 ----- [ anon ]
00007fe45a1fc000 8192 92 92 rw--- [ anon ]
00007fe45a9fc000 4 0 0 ----- [ anon ]
00007fe45a9fd000 8192 92 92 rw--- [ anon ]
00007fe45b1fd000 4 0 0 ----- [ anon ]
00007fe45b1fe000 8192 92 92 rw--- [ anon ]
00007fe45b9fe000 4 0 0 ----- [ anon ]
00007fe45b9ff000 8192 92 92 rw--- [ anon ]
00007fe45c1ff000 4 0 0 ----- [ anon ]
00007fe45c200000 8192 2048 2048 rw--- [ anon ]
00007fe45ca00000 30720 18076 18076 rw--- [ anon ]
00007fe45e9fe000 4 0 0 ----- [ anon ]
00007fe45e9ff000 8192 72 72 rw--- [ anon ]
00007fe45f1ff000 2048 1704 1704 rw--- [ anon ]
00007fe45f3ff000 4 0 0 ----- [ anon ]
00007fe45f400000 8192 2048 2048 rw--- [ anon ]
00007fe45fc00000 2048 2048 2048 rw--- [ anon ]
00007fe45fefe000 4 0 0 ----- [ anon ]
00007fe45feff000 8192 72 72 rw--- [ anon ]
00007fe4606ff000 4 0 0 ----- [ anon ]
00007fe460700000 8192 72 72 rw--- [ anon ]
00007fe460f00000 9216 8200 8200 rw--- [ anon ]
00007fe4619eb000 4 0 0 ----- [ anon ]
00007fe4619ec000 8192 44 44 rw--- [ anon ]
00007fe4621ec000 4 0 0 ----- [ anon ]
00007fe4621ed000 8192 44 44 rw--- [ anon ]
00007fe4629ed000 4096 3884 3884 rw--- [ anon ]
00007fe462ded000 48 48 0 r-x-- libnss_files-2.17.so
00007fe462df9000 2044 0 0 ----- libnss_files-2.17.so
00007fe462ff8000 4 4 4 r---- libnss_files-2.17.so
00007fe462ff9000 4 4 4 rw--- libnss_files-2.17.so
00007fe462ffa000 24 0 0 rw--- [ anon ]
00007fe463000000 8192 6144 6144 rw--- [ anon ]
00007fe46399b000 256 104 104 rw--- [ anon ]
00007fe4639db000 84 84 0 r-x-- libgcc_s-4.8.5-20150702.so.1
00007fe4639f0000 2044 0 0 ----- libgcc_s-4.8.5-20150702.so.1
00007fe463bef000 4 4 4 r---- libgcc_s-4.8.5-20150702.so.1
00007fe463bf0000 4 4 4 rw--- libgcc_s-4.8.5-20150702.so.1
00007fe463bf1000 932 508 0 r-x-- libstdc++.so.6.0.19
00007fe463cda000 2048 0 0 ----- libstdc++.so.6.0.19
00007fe463eda000 32 32 32 r---- libstdc++.so.6.0.19
00007fe463ee2000 8 8 8 rw--- libstdc++.so.6.0.19
00007fe463ee4000 84 12 12 rw--- [ anon ]
00007fe463ef9000 1808 1676 0 r-x-- libc-2.17.so
00007fe4640bd000 2044 0 0 ----- libc-2.17.so
00007fe4642bc000 16 16 16 r---- libc-2.17.so
00007fe4642c0000 8 8 8 rw--- libc-2.17.so
00007fe4642c2000 20 20 20 rw--- [ anon ]
00007fe4642c7000 1028 548 0 r-x-- libm-2.17.so
00007fe4643c8000 2044 0 0 ----- libm-2.17.so
00007fe4645c7000 4 4 4 r---- libm-2.17.so
00007fe4645c8000 4 4 4 rw--- libm-2.17.so
00007fe4645c9000 8 8 0 r-x-- libdl-2.17.so
00007fe4645cb000 2048 0 0 ----- libdl-2.17.so
00007fe4647cb000 4 4 4 r---- libdl-2.17.so
00007fe4647cc000 4 4 4 rw--- libdl-2.17.so
00007fe4647cd000 92 76 0 r-x-- libpthread-2.17.so
00007fe4647e4000 2044 0 0 ----- libpthread-2.17.so
00007fe4649e3000 4 4 4 r---- libpthread-2.17.so
00007fe4649e4000 4 4 4 rw--- libpthread-2.17.so
00007fe4649e5000 16 4 4 rw--- [ anon ]
00007fe4649e9000 28 28 0 r-x-- librt-2.17.so
00007fe4649f0000 2044 0 0 ----- librt-2.17.so
00007fe464bef000 4 4 4 r---- librt-2.17.so
00007fe464bf0000 4 4 4 rw--- librt-2.17.so
00007fe464bf1000 36 4 0 r---- libjemalloc.so.2
00007fe464bfa000 696 284 0 r-x-- libjemalloc.so.2
00007fe464ca8000 96 32 0 r---- libjemalloc.so.2
00007fe464cc0000 4 0 0 ----- libjemalloc.so.2
00007fe464cc1000 24 24 24 r---- libjemalloc.so.2
00007fe464cc7000 4 4 4 rw--- libjemalloc.so.2
00007fe464cc8000 2172 56 56 rw--- [ anon ]
00007fe464ee7000 136 136 0 r-x-- ld-2.17.so
00007fe464f0e000 1984 844 844 rw--- [ anon ]
00007fe465102000 24 24 24 rw--- [ anon ]
00007fe465108000 4 4 4 r---- ld-2.17.so
00007fe465109000 4 4 4 rw--- ld-2.17.so
00007fe46510a000 4 4 4 rw--- [ anon ]
00007ffcf3691000 132 52 52 rw--- [ stack ]
00007ffcf37f2000 16 0 0 r---- [ anon ]
00007ffcf37f6000 8 4 0 r-x-- [ anon ]
ffffffffff600000 4 0 0 --x-- [ anon ]


total kB 12473552 3884348 3876172
Can you explain why there is such a significant difference in memory statistics between the jeprof command and the other tools? I have analyzed multiple jeprof files.

I am using jemalloc version 5.3.0

Activity

  1. ylw510 commented on May 21, 2025

    @ylw510

    Maybe there are places in your program that use mmap, and this memory cannot be tracked by jemalloc?
    You can take a look at this issue #2785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions