I'm using valgrind 3.8.0.SVN from MacPorts on Mac OS X 10.7.4.
valgrind is showing a memory leak of 18 bytes when I try to allocate
an empty array using posix_memalign. The leak warning is attached.
The posix_memalign call is
void* data;
const size_t alignment = max(sizeof(T),sizeof(void*));
if (posix_memalign(&data,alignment,sizeof(T)*size))
throw bad_alloc();
where sizeof(T)==64 and size==0. I've confirmed that I call free on
the same pointer. If I replace the code with
void* data = malloc(sizeof(T)*size);
the leak warning goes away. Any idea what could be going wrong?
Thanks,
Geoffrey
==3094== HEAP SUMMARY:
==3094== in use at exit: 6,361,910 bytes in 3,106 blocks
==3094== total heap usage: 55,913 allocs, 52,807 frees, 40,466,216 bytes
allocated
==3094==
==3094== 18 bytes in 1 blocks are definitely lost in loss record 317 of 1,575
==3094== at 0xC8E6: malloc_zone_malloc (vg_replace_malloc.c:273)
==3094== by 0x6E88C6: malloc_set_zone_name (in
/usr/lib/system/libsystem_c.dylib)
==3094== by 0x6E8DF2: _malloc_initialize (in
/usr/lib/system/libsystem_c.dylib)
==3094== by 0x6E8EC4: posix_memalign (in /usr/lib/system/libsystem_c.dylib)
==3094== by 0x1EE024A: other::Array<other::Vector<pentago::super_t, 2>, 1>
pentago::aligned_buffer<other::Vector<pentago::super_t, 2> >(int) (aligned.h:30)
==3094== by 0x1EF36AF:
pentago::mpi::block_store_t::block_store_t(pentago::mpi::partition_t const&,
int, other::Array<pentago::mpi::line_t const, 1>) (block_store.cpp:55)
==3094== by 0x1EF2D82:
pentago::mpi::block_store_t::block_store_t(pentago::mpi::partition_t const&,
int, other::Array<pentago::mpi::line_t const, 1>) (block_store.cpp:70)
==3094== by 0x1EF66B7:
_ZN5otherL4new_IN7pentago3mpi13block_store_tEJRKNS2_11partition_tEiNS_5ArrayINS2_6line_tELi1EEEEEENS_3RefIT_EEDpOT0_
(new.h:24)
==3094== by 0x1EF533D:
pentago::mpi::meaningless_block_store(pentago::mpi::partition_t const&)
(block_store.cpp:141)
==3094== by 0x1EFC267:
_ZN5other22function_inner_wrapperIPFNS_3RefIN7pentago3mpi13block_store_tEEERKNS3_11partition_tEES5_JNS_3ITPILi0ES8_EEEEET0_P7_objectPv
(wrap_function.h:35)
==3094== by 0x1EFC132:
_ZN5other12OuterWrapperINS_3RefIN7pentago3mpi13block_store_tEEEJP7_objectPvEE4wrapIXadL_ZNS_22function_inner_wrapperIPFS5_RKNS3_11partition_tEES5_JNS_3ITPILi0ESE_EEEEET0_S7_S8_EEEES7_S7_S8_
(outer_wrapper.h:25)
==3094== by 0x2BC3BB7: other::PythonFunction::call(_object*, _object*,
_object*) (wrap_function.cpp:21)
==3094==
==3094== LEAK SUMMARY:
==3094== definitely lost: 18 bytes in 1 blocks
==3094== indirectly lost: 0 bytes in 0 blocks
==3094== possibly lost: 0 bytes in 0 blocks
==3094== still reachable: 6,183,686 bytes in 2,899 blocks
==3094== suppressed: 178,206 bytes in 206 blocks
==3094== Reachable blocks (those to which a pointer was found) are not shown.
==3094== To see them, rerun with: --leak-check=full --show-reachable=yes
==3094==
==3094== For counts of detected and suppressed errors, rerun with: -v
==3094== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 5647 from 210)
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users