Ivan Ristic wrote:
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);
}


I believe that's the stack reserved for each thread.
You can verify that by using either pmap or using ulimit to adjust the value and you will see the difference.

HTH,
Henry


Reply via email to