Memory leak

I have very bizzare problem with memory leak when I’m using my own classes (compiled with ACLiC) as a part of larger program. Unfortunatelly it is not easy to create minimal code which reproduce it - things can start/stop works even by rename objects…

Here is an error itself:

Two question:

  1. First of all to exclude that problem lies on definition of class side, please look at the header file:
#ifndef sym_h
#define sym_h

#include <iostream>
#include "TNamed.h"

using namespace std;

class sym: public TNamed
{
 private:
  int abc;

 public:
  sym();
  sym(const char* name);

  ClassDef(sym,1)
};

#endif

and source:

#include "sym.h"

ClassImp(sym)

sym::sym()
{;}

sym::sym(const char *name)
{
  SetName(name);
}

Is everything ok here?

  1. Memory leak appear when I’m closing the root file (TFile::Close()).
    TFile::Close() calls TDirectoryFile::Close() which calls
    fList->Delete() (fList is a objectof THashList) which calls
    TList::Delete() which calls
    TCollection::GarbageCollectTCollection(tlk->GetObject()) (tlk is TObjLink object) where object is finally deleted:
    delete obj;
    And problem occur when I’m using myown class with other root objects, e.g. histogram and during deletion of this histogram in GarbageCollection. It looks as if deletion is performed on nonexisting object. I suppose that histogram is somehow deleted during deletion of myown class (which was deleted previously). However I have access to this histogram just before delete (can check its name and so on). When I declare histogram before my own class in main program it is deleted first and problem doesn’t exists (it is probably still there by I delete “not crucial” part of memory).
    Any suggestion how to dubug it further?

Thank you very much in advance for any hints.

Hi jimmij,
1)[code]#ifndef sym_h
#define sym_h

#include
#include “TNamed.h”

using namespace std;

class sym: public TNamed
{
private:
int abc;

public:
sym();
sym(const char *name, const char *title);

ClassDef(sym, 1)
};

#endif

#include “sym.h”

ClassImp(sym)

sym::sym()
{;}

sym::sym(const char *name, const char *title) : TNamed(name, title)
{
;
}[/code]
2) plese see in ROOT UserGuide, chapter 8 - Object Ownership

I hope this help, Jan