Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: memory leak?



gfiala@s.netic.de(Guido Fiala)  26.08.02 19:52

Once upon a time Guido Fiala shaped the electrons to say...

>Did some tests with the following code:
>(gcc/g++ 2.95.3)

>#include <stdio.h>
>#include <unistd.h>
>#include <stdlib.h>
>#include <malloc.h>

>main()
>{
>        int i=0,j=0,k=0;
>        char s[256];
>        char *c;
>        initstate(99, s, 1000000L);
>        printf("vmsize is now?\n");
>        scanf("%i",&i);
>        for (i=0; i<1000000; i++)
>        {
>                k=random()/2000;
>                if (k>j) j=k;
>                c=(char*)malloc(k);
>                free(c);
>                //c=new (char)[k];
>                //delete(c);
>        }
>        printf("and now?\n");
>        scanf("%i",&i);
>        printf("max-malloc:%ld\n",j);
>        exit(0);
>}

>result with malloc:
>vmsize=1732 rss=580
>after
>vmsize=2756 rss=732 (that varies but not directly related with
>max-malloc)

>result with new/delete quite the same. However - only with random
>sizes! If you allocate always the same size the process shrinks at his
>previous vmsize value exactly (but a few kb rss more).

>What does that tell us?


That someone should ask the linux kernel group? ;-)



Rainer





Home | Main Index | Thread Index