Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mai__alek
Beginner
69 Views

[solved]pointer store in global vector cause memory leak?

seems to be our own problem.Sorry for interrupt

0 Kudos
1 Reply
Peter_W_Intel
Employee
69 Views

Please try Inspector XE 2016 Update 1 - which reported memory not deallocated (not memory leak).

$ g++ -g a.cpp

#include <vector>

using namespace std;

vector<int> *g_vec;

int main()
{
g_vec = new vector<int>;
g_vec->push_back(1);
return 1;
}

# inspxe-cl -c mi3 -- ./a.out
 
1 new problem(s) found
    1 Memory not deallocated problem(s) detected

$ inspxe-cl -R problems -verbose
P1: Warning: Memory not deallocated: Not fixed
 P1.3: Warning: Memory not deallocated: 24 Bytes: Not fixed
  /home/peter/a.cpp(9): Warning X3: Allocation site: Function main: Module /home/peter/a.out
  Code snippet:
    7  int main()
    8  {
   >9  g_vec = new vector<int>;
   10  g_vec->push_back(1);
   11  return 1;

  Stack (1 of 1 instance(s))
  >a.out!main - /home/peter/a.cpp:9
   libc.so.6!__libc_start_main - /lib64/libc.so.6:0x1ed59
   a.out!_start - /home/peter/a.out:0x7b4

 

 

Reply