[AGENT++] Memory management of AGENT++
wancheng82
wancheng82 at gmail.com
Wed Jul 28 07:22:13 CEST 2010
Apostolos,
Thank you.
You are right.
After removing the MAC, I find that arena is always equal to fordblks .
Robin
2010-07-28
wancheng82
发件人: Apostolos Manolitzas
发送时间: 2010-07-27 17:05:44
收件人: wancheng82
抄送: agentpp
主题: Re: [AGENT++] Memory management of AGENT++
On 07/27/2010 11:55 AM, wancheng82 wrote:
I use AGENT++ in one open source project (www.pica8.org), and it is very convenient.
I test very large MAC address table in BRIDGE-MIB.
At first it seems AGENT++ has memory leak int test 1.1) and 1.2), but when I do more test in 1.3) and 1.4), it suprises me.
Test 1)
1.1)Add 30000 MAC address to BRIDGE-MIB.
The code :
//MAC is in char buf[]
if((row = dot1dTpFdbEntry::instance->find_index(buf)) == NULL)
row = dot1dTpFdbEntry::instance->add_row(buf);
The memory test:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 23482 11.2 2.2 72772 68976 pts/10 S+ 16:43 0:02 ./agent =====>about 72MB
1.2)Rrmove 30000 MAC address from BRIDGE-MIB
The code:
//MAC is in char buf[]
if((row = dot1dTpFdbEntry::instance->find_index(buf)) != NULL)
dot1dTpFdbEntry::instance->remove_row(buf);
The memory test:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 23482 2.6 2.2 72772 68976 pts/10 S+ 16:43 0:04 ./agent ======>still about 72MB
1.3)Add another 30000 MAC address to BRIDGE-MIB(different from 1.1).
The code :
//MAC is in char buf[]
if((row = dot1dTpFdbEntry::instance->find_index(buf)) == NULL)
row = dot1dTpFdbEntry::instance->add_row(buf);
The memory test:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 23482 1.6 2.2 72772 68984 pts/10 S+ 16:43 0:06 ./agent ======>72MB
1.4)Rrmove 30000 MAC address from BRIDGE-MIB
The code:
//MAC is in char buf[]
if((row = dot1dTpFdbEntry::instance->find_index(buf)) != NULL)
dot1dTpFdbEntry::instance->remove_row(buf);
The memory test:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 23482 1.6 2.2 72772 68984 pts/10 S+ 16:43 0:08 ./agent ======>72MB
Question:
It seems that AGENT++ has its own memory management mechanism, is that right?
How should I know them from the code? I did not find them in code, because remove_row will delete the row.
Thank you.
Robin
Try to use struct mallinco [1] for actually metering the memory allocated and freed because Linux malloc implementation of stdlibc does some kind of caching in order to reuse the data.
Especially check the fordblks part.
cheers,
-Apostolos
[1] http://www.gnu.org/s/libc/manual/html_node/Statistics-of-Malloc.html#Statistics-of-Malloc
More information about the AGENTPP
mailing list