I have noticed that my multithreaded APR program consumes a *very*
large amount of virtual memory per thread and I can't think of a
reason why. I am running Debian 3.1  (latest kernel 2.6.8-3-686) and I
tried the test program below with both the APR 0.9.x that comes with
Debian and with the latest APR 1.2.x version.

In both cases I end up with around 800 MB of virtual RAM for 100 threads:
20385 ivanr     16   0  802m  956 1800 S  0.0  0.4   0:00.02 test

Am I doing something wrong or is this a bug? Any help is greatly appreciated!

void* APR_THREAD_FUNC thread_worker(apr_thread_t *thread, void *data) {
   apr_thread_exit(thread, 0);
}

int main(int argc, const char * const argv[]) {
   apr_pool_t *pool;
   int i;

   apr_app_initialize(&argc, &argv, NULL);
   atexit(apr_terminate);

   apr_pool_create(&pool, NULL);

   for(i = 0; i < 100; i++) {
       apr_thread_t *thread = NULL;
       apr_thread_create(&thread, NULL, thread_worker, NULL, pool);
   }

   apr_sleep(1000 * 1000 * 1000);
}

--
Ivan Ristic, Technical Director
Thinking Stone, http://www.thinkingstone.com
ModSecurity: Open source Web Application Firewall

Reply via email to