Memory leak from list<CloneList *>

Scott Kostyshak skostysh at lyx.org
Tue Feb 18 23:07:26 UTC 2020


Valgrind gave me the following error:

  ==732== 112 (72 direct, 40 indirect) bytes in 1 blocks are definitely lost in loss record 5,165 of 5,862
  ==732==    at 0x483AE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==732==    by 0x103A62D: lyx::Buffer::cloneBufferOnly() const (Buffer.cpp:661)
  ==732==    by 0x11E583C: lyx::(anonymous namespace)::copyToTempBuffer(lyx::ParagraphList const&, std::shared_ptr<lyx::DocumentClass const>) (CutAndPaste.cpp:582)
  ==732==    by 0x11E5C6A: lyx::(anonymous namespace)::putClipboard(lyx::ParagraphList const&, std::shared_ptr<lyx::DocumentClass const>, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, lyx::BufferParams) (CutAndPaste.cpp:613)
  ==732==    by 0x11E910B: lyx::cap::copySelection(lyx::Cursor const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) (CutAndPaste.cpp:1123)
  ==732==    by 0x11E84F8: lyx::cap::copySelection(lyx::Cursor const&) (CutAndPaste.cpp:1024)
  ==732==    by 0x13ECDAB: lyx::Text::dispatch(lyx::Cursor&, lyx::FuncRequest&) (Text3.cpp:1593)
  ==732==    by 0x1767E04: lyx::InsetText::doDispatch(lyx::Cursor&, lyx::FuncRequest&) (InsetText.cpp:339)
  ==732==    by 0x15FFC39: lyx::Inset::dispatch(lyx::Cursor&, lyx::FuncRequest&) (Inset.cpp:325)
  ==732==    by 0x11D1B13: lyx::Cursor::dispatch(lyx::FuncRequest const&) (Cursor.cpp:825)
  ==732==    by 0x1816F4F: lyx::frontend::GuiView::dispatchToBufferView(lyx::FuncRequest const&, lyx::DispatchResult&) (GuiView.cpp:3878)
  ==732==    by 0x181B959: lyx::frontend::GuiView::dispatch(lyx::FuncRequest const&, lyx::DispatchResult&) (GuiView.cpp:4569)

It comes from the following line (Buffer.cpp:661):

  cloned_buffers.push_back(new CloneList);

Currently cloned_buffers is a list<CloneList *>. Would it make sense to make it
a list of *smart* pointers instead? Alternatively we could make a class and
then make a custom destructor that would free the CloneLists that the list
elements point to?

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200218/8149974a/attachment.asc>


More information about the lyx-devel mailing list