c++ - Memory Leak - OpenMP -


valgrind told me, have following problem in code:

leak summary: ==18114==    lost: 0 bytes in 0 blocks ==18114==    indirectly lost: 0 bytes in 0 blocks ==18114==      possibly lost: 1,776 bytes in 3 blocks ==18114==    still reachable: 2,320 bytes in 4 blocks ==18114==         suppressed: 0 bytes in 0 blocks 

this problem occurs in:

#pragma omp parallel num_threads(numthreads) 

in

parallelcalc= new calculator[numoff];      #pragma omp parallel num_threads(numthreads)      for(int = 1; i<=numoff;i++)     {         std::stringstream sstm;         sstm << filename <<"/" << i<<".off";         std::string aktfilename = sstm.str();           polyhedron *poly = new polyhedron(aktfilename.c_str());         parallelcalc[i-1].init(poly,consistenttargets->points,numtarget);         parallelcalc[i-1].hfield();           delete poly;     } 

i tried set parallelcalc shared in openmp,(i think problem, isn't it?) when this, error maincontroller::parallelcalc not variable in clause shared. give me hint, how solve memory problem?

there's no way reproduce error because code not complete.

i see 1 potential loss of memory. have new calculator call no matching delete.

in addition, there other memory statically allocated indirect means there no way free.

one way figure out what's going on use valgrind in mode show specific items thinks leaked. use

valgrind --verbose --num-callers=30 --track-fds=yes --leak-check=full --show-reachable=yes

this dump lots more information allowing track down valgrind thinks leak coming from. use stack traces valgrind gives figure out if can safely ignore "leaks" because can't or if need fix code writing.


Comments