Memory allocation strategy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 1, 2011 at 9:12 PM, David Soulayrol
<david.soulayrol at gmail.com> wrote:
> Hello.
>
> I've got questions about memory pools management and I have found on
> the list a related question which was not answered as far as I can
> tell:
>
> http://article.gmane.org/gmane.comp.voip.pjsip/13275/match=pj_pool_release
>
> Here is a simple example. I have a hashtable which is instantiated
> from the very beginning of my program execution and which lasts until
> it ends. Many objects are added and then removed in this table. I need
> a pool to insert elements in this table, but I cannot use a global
> pool for all of them because it could lead to memory exhaustion. The
> solution I have found is to associate a pool to each entry in the
> table. So memory is freed when expired elements are removed from the
> table and destroyed. Does it sound good? What's your solution?
>

That's exactly what we do.

> More generally, how do you handle the problem of memory management
> when there can be unlimited successive allocations of objects with a
> long lifetime, like in the pjlib's balanced tree or hashtable ?

Didn't you answer this yourself above?

> Do you
> also use good ol' malloc at the same time?
>

Using malloc would be the same as admitting defeat, wouldn't it. So
no, no malloc.  :)

 Benny

> Thanks.
> --
> David
>
> _______________________________________________



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux