Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-6150

TCanvas::Update - PaintTitle leaks if canvas is non editable

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Medium
    • Resolution: Fixed
    • 5.34/00, 6.04.00, 6.02/08
    • 6.04.00, 5.34/30
    • Graphics
    • None
    • Linux Debian

    Description

      I found a leak at the THistPainter::PaintTitle() function. According to this report:
      http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15216
      the SetBit function delegates the ownership of ptitle for avoiding a memory leak. This is ok in the majority of cases, I agree, but it does not work when the TCanvas::SetEditable(kFALSE) is called. See the valgrind report with a minimalistic example below.

      In real time analysis applications, where each TCanvas might be updated every second and you may have 10 non-editable TGraphs, this a dangerously growing memory leak, around 22 MBytes/hour, 0.5GBytes / day.

      ==19072== Memcheck, a memory error detector
      ==19072== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
      ==19072== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
      ==19072== Command: root.exe -b -l -q test_editable.cpp+
      ==19072== Parent PID: 17081

      ==19072== 576 (264 direct, 312 indirect) bytes in 1 blocks are definitely lost in loss record 56,438 of 56,584
      ==19072== at 0x4C286E7: operator new(unsigned long) (vg_replace_malloc.c:287)
      ==19072== by 0x5013B08: TStorage::ObjectAlloc(unsigned long) (in /opt/root/lib/libCore.so)
      ==19072== by 0x15EEE3FE: THistPainter::PaintTitle() (in /opt/root/lib/libHistPainter.so)
      ==19072== by 0x15F00400: THistPainter::Paint(char const*) (in /opt/root/lib/libHistPainter.so)
      ==19072== by 0x15EE6E8D: TGraphPainter::PaintGraph(TGraph*, int, double const*, double const*, char const*) (in /opt/root/lib/libHistPainter.so)
      ==19072== by 0x15EDC266: TGraphPainter::PaintGraphSimple(TGraph*, char const*) (in /opt/root/lib/libHistPainter.so)
      ==19072== by 0xC3875E8: TPad::PaintModified() (in /opt/root/lib/libGpad.so)
      ==19072== by 0xC36242B: TCanvas::Update() (in /opt/root/lib/libGpad.so)
      ==19072== by 0x158B7D2D: test_editable() (test_editable.cpp:13)
      ==19072== by 0x158B7D78: G_test_editable_cpp_ACLiC_dict_0_1423(G_value*, char const*, G_param*, int) (test_editable_cpp_ACLiC_dict.cxx:80)
      ==19072== by 0x67805B6: Cint::G_ExceptionWrapper(int (Gvalue*, char const*, Gparam*, int), Gvalue*, char*, G_param*, int) (in /opt/root/lib/libCint.so)
      ==19072== by 0x6829960: G__execute_call (in /opt/root/lib/libCint.so)
      ==19072==
      ==19072== LEAK SUMMARY:
      ==19072== definitely lost: 264 bytes in 1 blocks
      ==19072== indirectly lost: 312 bytes in 3 blocks

      test_editable.cpp minimalistic example:

      #include "TCanvas.h"
      #include "TGraph.h"
       
      void test_editable()
      {
          
          TCanvas* c = new TCanvas();
          TGraph* g = new TGraph();
          g->SetPoint(0,120,0);
          g->SetTitle("mytitle");
          g->Draw("AL");
          c->SetEditable(kFALSE);//If I remove this line is present, the leak is gone
          c->Update();
          
          delete c;
          delete g;
      }

      Attachments

        Activity

          People

            bellenot Bertrand Bellenot
            fhuesogo Fernando Hueso Gonzalez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: