apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: apr_socket_create in short connect
Date Wed, 15 Apr 2015 12:14:41 GMT
On 04/15/2015 04:11 AM, GHui wrote:
> I use apr_socket_create in a short connect.
> And it takes up more and more memory as the program runs.
> Any help will be appreciated.
> --GHui

The normal way to handle that is to create a pool for data that must be 
maintained only for the life of that connection.  When the connection is 
over, clear the pool (apr_pool_clear) to make the memory available for 
reuse so that the process doesn't have to allocate more and more for the 
connection processing.

apr_pool_create(&foo, ...)
while (1) {
     apr_pool_clear(foo)
     apr_socket_create(foo, ...)
     ....
     apr_socket_close(...)
}


Mime
View raw message