You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Cosmin Luță <co...@avira.com> on 2011/07/27 12:15:49 UTC

APR threadpool and memory pool weirdness

Hi all,

I have a rather strange use case for APR which leads to quick memory
increase on Linux (at least): a program creates (in a loop) memory
pools which are passed to tasks in a threadpool. Each task will call
apr_pool_destroy on its pool (received as an argument). 

You can see the demo code here:

http://pastebin.com/KWPKsLrc

You can try to compile with:

gcc -g -O0 -o test_pools  `apr-1-config --cflags --includes
--cppflags`  -lapr-1 -laprutil-1 test_pools.c  

This is what I compile against (on an OpenSUSE 11.4 machine):

% rpm -qa | grep libapr
libapr-util1-debuginfo-1.3.9-9.2.x86_64
libapr1-devel-1.4.2-3.1.x86_64
libapr-util1-devel-1.3.9-9.2.x86_64
libapr-util1-1.3.9-9.2.x86_64
libapr1-1.4.2-3.1.x86_64
libapr1-debuginfo-1.4.2-3.1.x86_64


So, can anyone tell me what I'm missing here? I'm aware that it's not
very usual to create a pool in a thread, then pass it as a pointer to
another, but I don't think that's the source of the memory increase.
Any ideas what I can do to stop this from happening?


Best regards,


-- 
-- 
Cosmin Luță
Software Developer
AVIRA Soft srl



Re: APR threadpool and memory pool weirdness

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Wednesday 27 July 2011, Cosmin Luță wrote:
> I have a rather strange use case for APR which leads to quick
> memory increase on Linux (at least): a program creates (in a loop)
> memory pools which are passed to tasks in a threadpool. Each task
> will call apr_pool_destroy on its pool (received as an argument).

AFAICS due to the sleeps, you destroy pools at a max rate of 10/25ms 
while you create pools as fast as possible. Your memory usage will 
increase until all pools are created.

Re: APR threadpool and memory pool weirdness

Posted by Henry Jen <he...@ztune.net>.
Try to add a sleep call after push a couple tasks and see how that works.

Cheers,
Henry

2011/7/27 Cosmin Luță <co...@avira.com>:
> Hi all,
>
> I have a rather strange use case for APR which leads to quick memory
> increase on Linux (at least): a program creates (in a loop) memory
> pools which are passed to tasks in a threadpool. Each task will call
> apr_pool_destroy on its pool (received as an argument).
>
> You can see the demo code here:
>
> http://pastebin.com/KWPKsLrc
>
> You can try to compile with:
>
> gcc -g -O0 -o test_pools  `apr-1-config --cflags --includes
> --cppflags`  -lapr-1 -laprutil-1 test_pools.c
>
> This is what I compile against (on an OpenSUSE 11.4 machine):
>
> % rpm -qa | grep libapr
> libapr-util1-debuginfo-1.3.9-9.2.x86_64
> libapr1-devel-1.4.2-3.1.x86_64
> libapr-util1-devel-1.3.9-9.2.x86_64
> libapr-util1-1.3.9-9.2.x86_64
> libapr1-1.4.2-3.1.x86_64
> libapr1-debuginfo-1.4.2-3.1.x86_64
>
>
> So, can anyone tell me what I'm missing here? I'm aware that it's not
> very usual to create a pool in a thread, then pass it as a pointer to
> another, but I don't think that's the source of the memory increase.
> Any ideas what I can do to stop this from happening?
>
>
> Best regards,
>
>
> --
> --
> Cosmin Luță
> Software Developer
> AVIRA Soft srl
>
>
>