[ROOT] memory leak in TNtuple::Query / TTreeResult ?

From: Andre Holzner (Andre.Holzner@cern.ch)
Date: Sun Sep 23 2001 - 18:50:33 MEST


Hello rooters,


I'm using root 3.01/06 (10 August 2001) on Linux/i386.
I have the following small program:

#include <unistd.h>
#include <stdlib.h>
#include <TFile.h>
#include <TNtuple.h>
#include <TSQLResult.h>
#include <cassert>
#include <strstream>

//----------------------------------------------------------------------

void mem_usage()
{
  static pid_t pid = getpid();

  ostrstream buf;
  buf << "ps u -p " << pid << ends;
  system(buf.str());
}

//----------------------------------------------------------------------

void main()
{
  TFile *f = new TFile("hsimple.root"); assert(f!=NULL);
  TNtuple *tuple = (TNtuple *)f->Get("ntuple");  assert(tuple != NULL);

  int i;
  
  for (i=0; i<10000; ++i)
    {
      TSQLResult *query_res =
        tuple->Query("px:py:pz:random:i");
      delete query_res;

      if (i % 10 == 0)
        {
          cout << "i=" << i << endl;
          mem_usage();

        }    
    }
}


hsimple.root is the one from the $ROOTSYS/tutorials/ .
Now I expect this program to reach a constant memory usage after
the first iteration. However, the output which I get is the following:

i=0
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
holzner  18875 99.9  7.6 28732 20044 pts/5   S    18:43   0:03 ./test
i=10
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
holzner  18875 98.4 30.0 87328 78640 pts/5   S    18:43   0:29 ./test
i=20
USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
holzner  18875 98.3 52.4 145924 137236 pts/5 S    18:43   0:56 ./test


i.e. there is increase in memory usage of 58M per 10 iterations.
Or am I missing something ?

best regards & many thanks,


André

-- 
------------------+----------------------------------
Andre Holzner     | +41 22 76 76750 
Bureau 32 2-C13   | Building 32     
CERN              | Office 2-C13    
CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:00 MET