You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Steve doh <tf...@hotmail.com> on 2005/06/21 07:27:25 UTC
Freeing individual memory allocations allocated by apr_pcalloc()
Hi,
I have a heavily used linked list of memory objects allocated using
apr_pcalloc().
I have created a specific apr_pool just for this list.
How do I free the memory for a single object in this list after it has been
unlinked from the list?
I would normally use the apr_pool_destroy() function but this would wipe out
the whole linked list.
I can see that not freeing the unlinked objects will cause memory problems
after the program has been running for a while.
What am I missing?
Thanks for you help
Regards
Steve
_________________________________________________________________
Become a fitness fanatic @ http://xtramsn.co.nz/health
Re[2]: Freeing individual memory allocations allocated by apr_pcalloc()
Posted by David McIver <da...@optimatics.com>.
Tuesday, June 21, 2005 at 10:39:39 PM, Jeff typed:
JT> On 6/21/05, Steve doh <tf...@hotmail.com> wrote:
>> I have a heavily used linked list of memory objects allocated using
>> apr_pcalloc().
JT> ...
>> How do I free the memory for a single object in this list after it has been
>> unlinked from the list?
JT> you can't
Something like this may be a workable solution ...
. have your list data structure store the objects that have been unlinked
from the list
. when you need a new object, use one of the previously unlinked objects
. only allocate a new abject if no unlinked ones are available.
At least this way the memory used by your list would be bounded.
Cheers,
David
Re: Freeing individual memory allocations allocated by apr_pcalloc()
Posted by Jeff Trawick <tr...@gmail.com>.
On 6/21/05, Steve doh <tf...@hotmail.com> wrote:
> I have a heavily used linked list of memory objects allocated using
> apr_pcalloc().
...
> How do I free the memory for a single object in this list after it has been
> unlinked from the list?
you can't
> I can see that not freeing the unlinked objects will cause memory problems
> after the program has been running for a while.
> What am I missing?
APR pools may not be a match for the type of memory management that
this data structure requires.