memory measurement : different value between top/ps and mallinfo

L

lxu4net

There's a huge hash table in my application. I use it as a main
memory database. A lot of client write random data into the hash
table, so it call a lot of malloc() / free(). But after it run for
days, I watched it used a lot of memory. Finally it failed to call
malloc (). I use mallinfo() to watch the detail info. I found the
memory usage is different between the RSS value of "top" and
mallinfo().
"top" / "ps" tell me the application memory usage is 1.8G, but
mallinfo() say mallinfo.arena + mallinfo.hblkhd=1G.
Then I use pmap to see detail infomation. The "pmap" report 800M
"anon" blocks.

What's the "anon" blocks that "pmap" reported? Are they memory leak
or fragmentation? How can I avoid it?
 
K

Keith Thompson

lxu4net said:
There's a huge hash table in my application. I use it as a main
memory database. A lot of client write random data into the hash
table, so it call a lot of malloc() / free(). But after it run for
days, I watched it used a lot of memory. Finally it failed to call
malloc (). I use mallinfo() to watch the detail info. I found the
memory usage is different between the RSS value of "top" and
mallinfo().
"top" / "ps" tell me the application memory usage is 1.8G, but
mallinfo() say mallinfo.arena + mallinfo.hblkhd=1G.
Then I use pmap to see detail infomation. The "pmap" report 800M
"anon" blocks.

What's the "anon" blocks that "pmap" reported? Are they memory leak
or fragmentation? How can I avoid it?

The C language doesn't refer to mallinfo, RSS, top, ps, pmap, or
"anon" blocks. Try asking in a forum that deals with your system,
perhaps comp.unix.programmer or one of the Linux groups.
 
L

lxu4net

I found the mallinfo() only give main arena info. malloc_stats() can
give all arena info.
 
L

lxu4net

I found the mallinfo() only give main arena info. malloc_stats() can
give all arena info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top