Repository navigation
Open
Description
We've encountered that there is a junk of memory per loaded plugin not cleaned up.
When running a minimal example with valgrind, we see the following output:
==11631== 152 bytes in 1 blocks are indirectly lost in loss record 6 of 8
==11631== at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11631== by 0x528F670: class_loader::impl::AbstractMetaObjectBase::AbstractMetaObjectBase(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (meta_object.cpp:56)
==11631== by 0x791766A: ???
==11631== by 0x79172FE: ???
==11631== by 0x791710A: ???
==11631== by 0x7916E49: ???
==11631== by 0x7916F33: ???
==11631== by 0x7916F49: ???
==11631== by 0x40106B9: call_init.part.0 (dl-init.c:72)
==11631== by 0x40107CA: call_init (dl-init.c:30)
==11631== by 0x40107CA: _dl_init (dl-init.c:120)
==11631== by 0x40158E1: dl_open_worker (dl-open.c:575)
==11631== by 0x4010563: _dl_catch_error (dl-error.c:187)
==11631==
==11631== 267 (16 direct, 251 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 8
==11631== at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11631== by 0x79170F4: ???
==11631== by 0x7916E49: ???
==11631== by 0x7916F33: ???
==11631== by 0x7916F49: ???
==11631== by 0x40106B9: call_init.part.0 (dl-init.c:72)
==11631== by 0x40107CA: call_init (dl-init.c:30)
==11631== by 0x40107CA: _dl_init (dl-init.c:120)
==11631== by 0x40158E1: dl_open_worker (dl-open.c:575)
==11631== by 0x4010563: _dl_catch_error (dl-error.c:187)
==11631== by 0x4014DA8: _dl_open (dl-open.c:660)
==11631== by 0x6C78F08: dlopen_doit (dlopen.c:66)
==11631== by 0x4010563: _dl_catch_error (dl-error.c:187)
The original issue to this: ros2/rosbag2#23
fyi @Martin-Idel-SI
Metadata
Metadata
Assignees
Labels
No labels
Activity
mikaelarguedas commentedon Sep 11, 2018
@Martin-Idel-SI @Karsten1987 Is this only happening on shutdown ?
Or can you reproduce N * bytes leaked by loading and unloading the plugin N times ?
Martin-Idel-SI commentedon Sep 11, 2018
@mikaelarguedas No, it seems to only happen at shutdown.
Taking the example, I just duplicated the lines loading the plugin (here: https://github.com/bsinno/rosbag2/blob/8f1e7137e0e3dee13e9dc6b38213bfc3b62add3b/minimaldll/main.cpp#L26-30) and I still only see the one leak with the same amount of leaked memory
mikaelarguedas commentedon Sep 11, 2018
Thanks @Martin-Idel-SI for confirming
I suspect this is an optimization from Poco then, that knows the process is shutting down and there is no need to cleanup everything. I don't think there is much we can do on our side if that's the case
Karsten1987 commentedon Sep 11, 2018
what's happening if you put this line in a loop (let's say 10x) and load and unload the plugin everytime?
mikaelarguedas commentedon Sep 14, 2018
@Martin-Idel-SI can you check if ros/class_loader#103 fixes the issue ?
Karsten1987 commentedon Sep 17, 2018
valgrind still reports lost bytes with the minimal example.
I believe it's less than before though.
mikaelarguedas commentedon Sep 18, 2018
Thanks @Karsten1987 for trying it!
Can you post the report when you get a chance to compare to the one in the issue description?
Karsten1987 commentedon Sep 18, 2018
Sorry, should have mentioned it!