Bug #18915 2013-03-02 23:35

anyname

Memory leak when editing medium size files

If I try to save edits to a 2.3MB C file, code::blocks gets stuck requesting memory and eventually causes thrashing. Replicating this with a process viewer shows memory consumption grow at about 1GB/sec.

Category
Application::Crash
Group
Platform:Linux
Status
Open
Close date
 
Assigned to
mortenmacfly
mortenmacfly 2013-03-03 05:18

Exmaples, please. Cannot reproduce - even way larger files work just fine.

Version, platform?

anyname 2013-03-25 19:40
Release 12.11 rev 8629
SDK 1.13.14
Fedora 17/x86_64

It appears to have something to do with the trailing whitespace removal AND the size of the file. I have a testcase but I can't attach files and it's 1.3MB so I'm not sure how to demonstrate this. When I tested saving a 0.8MB version of the file, C::B allocated an 800MB chunk of memory so it seems it's not stuck in a loop it just wants excessive amounts of memory.

Here is the massif log from 'valgrind --tool=massif codeblocks' with the 1.3MB file. I killed it after it used 1.5GB of memory(after starting with 64MB).

#-----------
snapshot=61
#-----------
time=35987940494
mem_heap_B=1594864873
mem_heap_extra_B=4610999
mem_stacks_B=0
heap_tree=detailed
n2: 1594864873 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
 n2: 1566171728 0x3A848FDB8F: RunStyles::PersistantForm() const (in /usr/lib64/libcodeblocks.so.0.0.1)
  n1: 1566171716 0x3A848C731F: CellBuffer::DeleteChars(int, int, bool&) (in /usr/lib64/libcodeblocks.so.0.0.1)
   n1: 1566171716 0x3A848CEB1C: Document::DeleteChars(int, int) (in /usr/lib64/libcodeblocks.so.0.0.1)
    n1: 1566171716 0x3A848DAC8B: Editor::ReplaceTarget(bool, char const*, int) (in /usr/lib64/libcodeblocks.so.0.0.1)
     n1: 1566171716 0x3A848EC7AB: Editor::WndProc(unsigned int, unsigned long, long) (in /usr/lib64/libcodeblocks.so.0.0.1)
      n1: 1566171716 0x3A8474175C: ScintillaWX::WndProc(unsigned int, unsigned long, long) (in /usr/lib64/libcodeblocks.so.0.0.1)
       n1: 1566171716 0x3A8474870E: wxScintilla::ReplaceTarget(wxString const&) (in /usr/lib64/libcodeblocks.so.0.0.1)
        n1: 1566171716 0x3A845AE74C: cbEditorInternalData::StripTrailingSpaces() (in /usr/lib64/libcodeblocks.so.0.0.1)
         n1: 1566171716 0x3A845ABEBB: cbEditor::Save() (in /usr/lib64/libcodeblocks.so.0.0.1)
          n1: 1566171716 0x48124E: MainFrame::OnFileSave(wxCommandEvent&) (in /usr/bin/codeblocks)
           n1: 1566171716 0x308AAE6794: wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
            n1: 1566171716 0x308AAE6902: wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
             n1: 1566171716 0x308AAE6C25: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
              n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
               n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                 n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                  n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                   n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                    n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                     n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                      n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                       n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                        n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                         n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                          n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                           n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                            n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                             n1: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
                              n0: 1566171716 0x308AAE6BAE: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib64/libwx_baseu-2.8.so.0.8.0)
anyname 2013-03-25 19:48

This replicates the issue for me:

Make a text file consisting of 35,000 copies of the following line, including the 12 spaces at the end:

abcdefghijlkmnopqrstuvwxyz abcdefghijlkmnopqrstuvwxyz

Open it in C::B then try to save it after modifying one character. Trailing space removal needs to be enabled of course.

tpetrov 2013-10-04 22:51

I can confirm that doing the steps from the last comment cause C::B to use excessive amounts of memory.