Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4998 Discussions

Inspector unable to detect memory leak

manik_s_
Beginner
475 Views

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 ?

 

0 Kudos
1 Reply
Peter_W_Intel
Employee
475 Views

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, 0, funcA, NULL);

       }

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

        return 0;
}

0 Kudos
Reply