Inspector unable to detect memory leak

Inspector unable to detect memory leak

I have a function that allocates memory like :

void funcA(void* args)

{

   char* memory_leak = (char*)malloc(1000);

}

now I create a thread on this function, which therefore must allocate the mentioned memory, and exit.

My application is multi-threaded and I have created one more thread on this function.

But when I run Intel Inspector on my application, it doesnt show this as a memory leak.

I ran both mi1 and mi2 level of memory analysis but this leak was not detected.

Any ideas ?

 

2 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Sorry that I cannot reproduce the problem you reported. Use your example code -

1. g++ -g test0.cpp -o test0 -lpthread

2. # inspxe-cl -version
Intel(R) Inspector XE 2013 Update 9 (build 328075) Command Line tool
Copyright (C) 2009-2013 Intel Corporation. All rights reserved.

3.# inspxe-cl -version
Intel(R) Inspector XE 2013 Update 9 (build 328075) Command Line tool
Copyright (C) 2009-2013 Intel Corporation. All rights reserved.
[root@snb01 problem_report]# ^C
[root@snb01 problem_report]# inspxe-cl -collect mi2 -- ./test0
  
1 new problem(s) found 
    1 Memory leak problem(s) detected 

4. # inspxe-cl -collect mi2 -- ./test0
  
1 new problem(s) found 
    1 Memory leak problem(s) detected 
[root@snb01 problem_report]# ^C
[root@snb01 problem_report]# inspxe-cl -report problems
P1: Error: Memory leak
 P1.50: Memory leak: 16000 Bytes: New
  /home/peter/problem_report/test0.cpp(12): Error X50: Allocation site: Function funcA: Module /home/peter/problem_report/test0

 

--------------------------------------------------------------------------------------------------------------------------------------

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

#define NUM_THREADS 16

void * funcA(void* args)

{

   char* memory_leak = (char*)malloc(1000);

}

int main()
{
        int i;
        pthread_t h[NUM_THREADS];

        for (i = 0; i < NUM_THREADS; ++i)
        {
                pthread_create(&h[i], 0, funcA, NULL);

       }

        for (i = 0; i < NUM_THREADS; ++i)
            pthread_join (h[i], 0);

        return 0;
}

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!