> > I tried to create sub-pool for each object as workaround. This hits > > memory footprint and performance. > > You are correct about that. There is no free call. Memory can > be either reused by calling apr_pool_clear or freed by calling > apr_pool_destroy. > Because for any IO system object (file, socket, mutex, etc.) > you usually need some additional struct, the standard implementation > look like: > struct my_struct; > my_struct = malloc(...); > my_truct->fh = open(...) > ... do something with object > close(my_truct->fh); > free(my_struct); > > With APR it would look like: > > struct my_struct; > pool = apr_pool_create(...) > my_struct = apr_palloc(pool, ...) > my_truct->fh = apr_xxx_open(pool, ...) > ... do something with object > apr_xxx_close(my_truct->fh); > apr_pool_destroy(pool); > > Since each created object has it's own cleanup function > when calling apr_pool_destroyed all objects created with > that pool will call it's cleanup functions, so there is > no need to call the apr_xxx_close. >
I tried to do as you recommended: create pool for each portLib object. The only problem here is a memory footprint. Each apr_pool_create(...) allocates 8k memory: #define MIN_ALLOC 8192 Thus each portLib object costs 8k. I would be happy with at least SUGGGESTED_SIZE parameter in apr_pool_create() function. APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, apr_pool_t *parent, apr_abortfunc_t abort_fn, apr_allocator_t *allocator apr_size_t SUGGGESTED_SIZE Thank you, Artem Aliev Intel Middleware Products Division