Best practices for memory pool usage in modules?
I'm looking into memory leak issues with mod_skinny, and it seems clear that it's repeatedly allocating memory when it doesn't really need to hang onto it permanently. Since it has both a long standing connection to each device (listener) and has requests coming in regularly that currently are allocating memory and appear to be leaking it since the listener stays around. Would having the code allocate a new temporary sub-pool for each request that comes in be appropriate, or would it be better to just use regular malloc for those allocate/use/destroy cases? -- Nathan ------------------------------------------------------------ Nathan Neulinger nneul@mst.edu Missouri S&T Information Technology (573) 612-1412 System Administrator - Architect
If the object has a complex life cycle then pools are better. If its short lived frequent little one-off allocations may as well malloc On Aug 2, 2013 4:40 PM, "Nathan Neulinger" <nneul@mst.edu> wrote:
I'm looking into memory leak issues with mod_skinny, and it seems clear that it's repeatedly allocating memory when it doesn't really need to hang onto it permanently.
Since it has both a long standing connection to each device (listener) and has requests coming in regularly that currently are allocating memory and appear to be leaking it since the listener stays around.
Would having the code allocate a new temporary sub-pool for each request that comes in be appropriate, or would it be better to just use regular malloc for those allocate/use/destroy cases?
-- Nathan
------------------------------------------------------------ Nathan Neulinger nneul@mst.edu Missouri S&T Information Technology (573) 612-1412 System Administrator - Architect
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
In almost all of these cases, it's "allocate space to package up a message/pdu then send it over the socket", so it sounds like a simple malloc makes more sense. -- Nathan On 08/02/2013 05:46 PM, Anthony Minessale wrote:
If the object has a complex life cycle then pools are better. If its short lived frequent little one-off allocations may as well malloc
On Aug 2, 2013 4:40 PM, "Nathan Neulinger" <nneul@mst.edu <mailto:nneul@mst.edu>> wrote:
I'm looking into memory leak issues with mod_skinny, and it seems clear that it's repeatedly allocating memory when it doesn't really need to hang onto it permanently.
Since it has both a long standing connection to each device (listener) and has requests coming in regularly that currently are allocating memory and appear to be leaking it since the listener stays around.
Would having the code allocate a new temporary sub-pool for each request that comes in be appropriate, or would it be better to just use regular malloc for those allocate/use/destroy cases?
-- Nathan
------------------------------------------------------------ Nathan Neulinger nneul@mst.edu <mailto:nneul@mst.edu> Missouri S&T Information Technology (573) 612-1412 <tel:%28573%29%20612-1412> System Administrator - Architect
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org <mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- ------------------------------------------------------------ Nathan Neulinger nneul@mst.edu Missouri S&T Information Technology (573) 612-1412 System Administrator - Architect
participants (2)
-
Anthony Minessale
-
Nathan Neulinger