#292 The TXC 2.0 build 1162 contains a memory leak.

closed-fixed
None
5
2010-09-09
2010-08-30
Andreas Kiefer
No
0 up votes | 0 down votes | 0%
4 comments

The destruction of a CStyleFileContainer at program exit should remove and delete all associated style files stored in the element m_StyleFiles, but unfortunately it doesn't.
The reason for this lies in the cyclic dependency between CStyleFile and CNewCommand, namely CStyleFile::m_Commands and CNewCommand::m_Parent (resp. CAbstractCommand::m_Parent because of inheritance). So, a style file contains commands, which in turn reference the style file; removing a style file from the CStyleFileContainer::m_StyleFiles doesn't delete it, because the reference counter maintained by the shared_ptr isn't zero.

A possible solution is enclosed in the diff file. It solves the problem by iterating through all style files and clearing each CStyleFile::m_Commands. It succeeds in deleting all objecs at exit, but isn't tested very well and may contain some problems when clearing the map at runtime.

Discussion

  • Sergiu Dotenco
    Sergiu Dotenco
    2010-09-09

    • labels: 434620 -->
    • milestone: 1143860 -->
    • assigned_to: nobody --> sergiudotenco
     
  • Sergiu Dotenco
    Sergiu Dotenco
    2010-09-09

    The described error has been added to the official bug list.

    Thank you for your report.

     
  • Sergiu Dotenco
    Sergiu Dotenco
    2010-09-09

    Thanks for the patch. There's a std::weak_ptr<>, however, used to break cyclic dependencies which I used for CAbstractLatexCommand::m_Parent instead.

     


Anonymous


Cancel   Add attachments