apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ioan Popescu <ipope...@dataq.com>
Subject APR Pools - efficiency
Date Fri, 03 Nov 2006 20:19:55 GMT
Well, I ran my "benchmark" to see what performance APR pools can provide and
found that they do provide an advantage. Somewhere around 80 times better
performance! I guess that makes sense though...

I do have a question I found puzzling. I had break points at the three
statements indicated. I used "Task Manager" to check the memory and virtual
memory usage of the program. When reaching break 1, memory usage was 1388K
and virtual memory usage was 476K. When reaching break 2, no change. When
reaching break 3, memory usage was 2300K and virtual memory usage was 808K.
Is this a memory leak somewhere or what?

System:
Windows XP SP2
VS 2005
APR 1.2.7

Here's the code I used to run the test:
--- begin code ---
#include "apr_pools.h"

int main(int argc, char *argv[], char *env[])
{
    int arr[] = {3000, 2000, 1500, 1300, 1100, 1000, 500, 60};
    int i = 0, j = 0, k = 8000;
    LARGE_INTEGER i1, i2, reff;
    LARGE_INTEGER j1, j2;
    void *a1 = NULL;
    apr_pool_t *a2;
    double r1 = 0, r2 = 0;

    QueryPerformanceFrequency(&reff);

    QueryPerformanceCounter(&j1);			/* break 1 */
    for(i=0; i<k; i++, j++)
    {
        if(j >= sizeof(arr)/sizeof(*arr)) j=0;
        a1 = malloc(arr[j]);
        if(a1 != NULL) free(a1);
    }
    QueryPerformanceCounter(&j2);

    apr_app_initialize(&argc, &argv, &env);		/* break 2 */

    apr_pool_create(&a2, NULL);
    QueryPerformanceCounter(&i1);
    for(i=0; i<k; i++, j++)
    {
        apr_pool_clear(a2);
        if(j >= sizeof(arr)/sizeof(*arr)) j = 0;
        a1 = apr_palloc(a2, arr[j]);
    }
    QueryPerformanceCounter(&i2);
    apr_pool_destroy(a2);

    apr_terminate();

    r1 = (i2.QuadPart - i1.QuadPart)/(double)reff.QuadPart;
    r2 = (j2.QuadPart - j1.QuadPart)/(double)reff.QuadPart;

    return 0;						/* break 3 */
}
--- end code ---

Mime
View raw message