You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Pierre Laplante <la...@sednove.ca> on 2006/08/18 22:25:44 UTC

apr_allocator_max_free_set

I used the following codes to set back the memory usage of a httpd 
process using apr for pool allocation. The value of freealloc
can vbe adjust using configuration directive in httpd.conf.

If I put 1024, and allocate 500 Mb, the memory is release
If I put 8192, the memory is never release.

Do you know what is the problem,

 apr_allocator_t* pa = apr_pool_allocator_get(r->pool);
  if (pa) {
    SNDEBUGS(r->server, "freealloc = %d", conf -> freealloc);
    if (conf -> freealloc != 0)
      apr_allocator_max_free_set(pa, conf -> freealloc);
    else
      apr_allocator_max_free_set(pa, 2048);


The following code allocate the memory:

apr_pool_t *mypool;
    apr_status_t res = apr_pool_create(&mypool,  r->pool);
   
    SNDEBUGS(r->server, "maxi=%d, maxj=%d", maxi, maxj);
    int nb=0;
    for(j=0;j<maxj;++j) {
      for(i=0;i<maxi;++i) {
      char *fulltmpdir = apr_palloc(mypool,1000);
      nb += 1000;
      }
    }

    SNDEBUGS(r -> server, "wait 10 secondes allocation=%d Mb\n", 
nb/1024/1024);
    sleep(10);
    apr_pool_destroy(mypool);

thanks