You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by GHui <ug...@gmail.com> on 2015/08/19 13:02:05 UTC

How to release apr_socket_accept memory pool

I code a server with apr_socket_accept and apr_pollset_poll. But apr_socket_accept and apr_pollset_add take up the memory pool. I cann't release or clear memory pool. So it take up more and more memory. 
Any help will be appreciated. -GHui

Re: How to release apr_socket_accept memory pool

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Aug 20, 2015 at 4:12 AM, GHui <ug...@gmail.com> wrote:
>
> On  Thu, 2015-08-20 at 6:30 AM , Nick wrote:
>
>>Can you not solve that problem by using a subpool for those
>>functions?  That way you can give the subpool the lifetime
>>you need it to have, regardless of other resources that
>>prevent you clearing the parent pool.
>
>
> If do this, every connect need create a subpool, and clear mpool when close
> the connect.

Pools can be recycled in an aside list (or APR_RING), after being
cleared (which closes the socket), so that the next connections will
either reuse an existing/idle pool or create a new one (lately
recycled).
You may also use an apr_reslist of pools if you need synchronization
and native parameters to handle the pools' limits/lifetime in the
list.

This both ovoids leaks and becomes optimaly efficient once the maximum
number of connections have been reached (all pools are reused).

Re: How to release apr_socket_accept memory pool

Posted by GHui <ug...@gmail.com>.
On  Thu, 2015-08-20 at 6:30 AM , Nick wrote:


>On Wed, 2015-08-19 at 19:02 +0800, GHui wrote:

>> I code a server with apr_socket_accept and apr_pollset_poll. But
>> apr_socket_accept and apr_pollset_add take up the memory pool. I
>> cann't release or clear memory pool. So it take up more and more
>> memory. 

>Can you not solve that problem by using a subpool for those
>functions?  That way you can give the subpool the lifetime
>you need it to have, regardless of other resources that
>prevent you clearing the parent pool.

 


If do this, every connect need create a subpool, and clear mpool when close the connect.

Re: How to release apr_socket_accept memory pool

Posted by Nick Kew <ni...@apache.org>.
On Wed, 2015-08-19 at 19:02 +0800, GHui wrote:

> I code a server with apr_socket_accept and apr_pollset_poll. But
> apr_socket_accept and apr_pollset_add take up the memory pool. I
> cann't release or clear memory pool. So it take up more and more
> memory. 

Can you not solve that problem by using a subpool for those
functions?  That way you can give the subpool the lifetime
you need it to have, regardless of other resources that
prevent you clearing the parent pool.

-- 
Nick Kew