Author Topic: memory leak?  (Read 2824 times)

Offline AZ

  • Almost regular
  • **
  • Posts: 151
memory leak?
« on: October 12, 2012, 04:32:39 am »
hello,
 i'm using the svn build 8403 with Valgrind plugin 1.0. Running valgrind 3.6 on RHEL 6.3 with gcc 4.4.6

It apperas that after using vagrind plugin the memory is not getting released somehow. Here is how to reproduce:

Code
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    long max_num = 4 ;
    long* prime_arr = NULL;
    max_num = 65536000 ;
    max_num = max_num < 4L?4L:max_num;
    printf("max num %ld\n",max_num);
    prime_arr = (long*)malloc(max_num * sizeof(long));
    for (long i = 1; i  < max_num; i++) {
        prime_arr[i] = i ;
    }

    for (long p=2; p <= max_num; p++) {
        for (long i = 2; i < max_num && p*i < max_num; i++) {
            prime_arr[p*i] = 0L;
        }
    }

    printf("\n Primes are :\n") ;
    for (long i=1; i< max_num; i++)
        if (prime_arr[i] != 0)
            printf("%ld \n",prime_arr[i]);
 free(prime_arr);
    return EXIT_SUCCESS;
}

build/run - i can observe the mem usage goes up by ~500 Mb and after program is completed. the mem usage goes back to the original level.

now, invoke valgrind from the plugins. Warning  - on my AMD 4 system it takes about 5 minutes to complete. The mem usage goes up significuntly ( as exepcted), but it doesn't go down to the original level EVEN AFTER the execution is over.

CB: nightly build .
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)