Domanda

I have a memory leak that only appears when I compile with OpenMP support and GNU Parallel extensions: -fopenmp -DGLIBCXX_PARALLEL.

Example :

std::transform(buffer, buffer + _tabLength, _origData, MathUtil::ShortToDouble);

Result (sorry for the valgrind template horror):

==7109== 912 bytes in 3 blocks are possibly lost in loss record 3 of 4
==7109==    at 0x4C29C64: calloc (vg_replace_malloc.c:593)
==7109==    by 0x4010F29: allocate_dtv (dl-tls.c:296)
==7109==    by 0x401163D: _dl_allocate_tls (dl-tls.c:460)
==7109==    by 0x5C505B8: pthread_create@@GLIBC_2.2.5 (allocatestack.c:579)
==7109==    by 0x582D1C5: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7109==    by 0x4309DB: double (*__gnu_parallel::__for_each_template_random_access_workstealing<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, double (*)(short), __gnu_parallel::__transform1_selector<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >, __gnu_parallel::_DummyReduct, bool>(__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, __gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, double (*)(short), __gnu_parallel::__transform1_selector<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >&, __gnu_parallel::_DummyReduct, bool, bool&, std::iterator_traits<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >::difference_type))(short) (workstealing.h:139)
==7109==    by 0x42F6C8: double (*__gnu_parallel::__for_each_template_random_access<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, double (*)(short), __gnu_parallel::__transform1_selector<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >, __gnu_parallel::_DummyReduct, bool>(__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, __gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag>, double (*)(short), __gnu_parallel::__transform1_selector<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >&, __gnu_parallel::_DummyReduct, bool, bool&, std::iterator_traits<__gnu_parallel::_IteratorPair<short*, double*, std::random_access_iterator_tag> >::difference_type, __gnu_parallel::_Parallelism))(short) (for_each.h:86)
==7109==    by 0x42EAF3: double* std::__parallel::__transform1_switch<short*, double*, double (*)(short)>(short*, short*, double*, double (*)(short), std::random_access_iterator_tag, std::random_access_iterator_tag, __gnu_parallel::_Parallelism) (algo.h:1240)
==7109==    by 0x42E329: double* std::__parallel::transform<short*, double*, double (*)(short)>(short*, short*, double*, double (*)(short)) (algo.h:1293)

Any idea of how to solve this ?

È stato utile?

Soluzione

It's not a real leak. It's TSD (thread specific data) that does not need to be recovered while the thread is running.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top