[AGENT++] Memory management of AGENT++
Apostolos Manolitzas
manap at intracom.gr
Tue Jul 27 11:05:34 CEST 2010
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