[AGENT++] Memory management of AGENT++

wancheng82 wancheng82 at gmail.com
Tue Jul 27 10:55:55 CEST 2010


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




More information about the AGENTPP mailing list