Re: [ROOT] memory hog

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Feb 21 2001 - 17:58:30 MET


Hi Michael,
As you can see in the output of the second gObjectTable->Print(), you have
a beautiful memory leak:
  TObjArray               64149      64149       40       2565960      256596
  TkrLayer                64000      64000       36       2304000      2304000
  StripID                 35502      35502       16        568032       568032

You never delete the TkrLayer objects. Each of these objects has a TObjArray
of StripID.
I do not see any indication in Event.h where these objects are created.
Looking into your Event destructor, I see that you have commented the end.
This was may be very relevant. I have a comment on your destructor.
You can replace the lines of code like:

        int nEntries = m_CAL->GetEntries();
        for (int i=0; i<nEntries; i++)
            delete m_CAL->At(i);
        m_CAL->Clear();
by
        m_CAL->Delete();

Rene Brun


Michael Kuss wrote:
> 
> Hi Rene,
> 
> thanks for the quick reply.
> 
> > If you have a file named ".rootrc" in your current directory, add the following
> > 2 lines:
> > Root.MemStat:            1
> > Root.ObjectStat:         1
> 
> Indeed, this made it more verbose:
> 
> Object statistics
> class                     cnt    on heap     size    total size    heap size
> ============================================================================
> TTree                       2          2      256           512          512
> TObject                    54         54       12           648          648
> TObjArray                 139        139       40          5560         5560
> TBranchObject              14         14      268          3752         3752
> TBranch                     8          8      256          2048         2048
> TLeafI                      8          8       72           576          576
> TBasket                    21         21      116          2436         2436
> TKey                        4          4       80           320          320
> TLeafObject                14         14       68           952          952
> L1T                         1          1       36            36           36
> Tagger                      1          1       24            24           24
> Event                       1          1       44            44           44
> TFile                       2          2      176           352          352
> TStreamerBasicType         36         36       92          3312         3312
> TRealData                 417        417       36         15012        15012
> TDataMember               156        156       36          5616         5616
> TList                     186        186       44          8184         8184
> TDataType                  83         83       32          2656         2656
> TStreamerString             4          4       88           352          352
> TStreamerObject             5          5       92           460          460
> TMethodCall                 6          6       60           360          360
> TClass                     58         58       80          4640         4640
> THashTable                  8          8       40           320          320
> TObjectTable                1          1       24            24           24
> TStreamerBase              10         10       88           880          880
> TVirtualX                   1          1       84            84           84
> TStreamerObjectAny          2          2       92           184          184
> TStyle                      5          5      744          3720         3720
> TBuffer                    21         21       52          1092         1092
> TBaseClass                 21         21       32           672          672
> TOrdCollection              5          5       44           220          220
> TFolder                    16         16       36           576          576
> TSystemDirectory            1          1       36            36           36
> TStreamerInfo              10         10       76           760          760
> TStreamerObjectPointer        1          1       92            92           92
> TRandom                     1          1       32            32           32
> TStreamerBasicPointer        3          3      112           336          336
> THashList                   8          8       48           384          384
> TFree                       1          1       20            20           20
> TROOT                       1          0      256           256            0
> TCint                       1          1      224           224          224
> TClassTable                 1          1       12            12           12
> TMessageHandler             1          1       56            56           56
> TUnixSystem                 1          1      320           320          320
> TEnv                        1          1       24            24           24
> TGuiFactory                 1          1       28            28           28
> ----------------------------------------------------------------------------
> Total:                   1342       1341     4580         68204        67948
> ============================================================================
> 
> Object statistics
> class                     cnt    on heap     size    total size    heap size
> ============================================================================
> TTree                       2          2      256           512          512
> TObject                    54         54       12           648          648
> TObjArray               64149      64149       40       2565960      2565960
> TBranchObject              14         14      268          3752         3752
> TBranch                     8          8      256          2048         2048
> TLeafI                      8          8       72           576          576
> TBasket                   136        136      116         15776        15776
> TKey                        5          5       80           400          400
> TLeafObject                14         14       68           952          952
> L1T                         1          1       36            36           36
> Tagger                      1          1       24            24           24
> Event                       1          1       44            44           44
> TFile                       2          2      176           352          352
> TStreamerBasicType         36         36       92          3312         3312
> TRealData                 417        417       36         15012        15012
> TDataMember               156        156       36          5616         5616
> TList                     198        198       44          8712         8712
> TDataType                  83         83       32          2656         2656
> TStreamerString             4          4       88           352          352
> TStreamerObject             5          5       92           460          460
> TMethodCall                 6          6       60           360          360
> TClass                     63         63       80          5040         5040
> THashTable                  8          8       40           320          320
> TObjectTable                1          1       24            24           24
> TStreamerBase              10         10       88           880          880
> TVirtualX                   1          1       84            84           84
> TStreamerObjectAny          2          2       92           184          184
> TStyle                      5          5      744          3720         3720
> TBuffer                   136        136       52          7072         7072
> TBaseClass                 23         23       32           736          736
> TOrdCollection              5          5       44           220          220
> TFolder                    16         16       36           576          576
> TSystemDirectory            1          1       36            36           36
> TStreamerInfo              10         10       76           760          760
> TStreamerObjectPointer        1          1       92            92           92
> TRandom                     1          1       32            32           32
> TStreamerBasicPointer        3          3      112           336          336
> THashList                   8          8       48           384          384
> TFree                       1          1       20            20           20
> TROOT                       1          0      256           256            0
> TCint                       1          1      224           224          224
> TClassTable                 1          1       12            12           12
> TMessageHandler             1          1       56            56           56
> TUnixSystem                 1          1      320           320          320
> TEnv                        1          1       24            24           24
> TGuiFactory                 1          1       28            28           28
> TkrLayer                64000      64000       36       2304000      2304000
> StripID                 35502      35502       16        568032       568032
> TExMap                    115        115       24          2760         2760
> ----------------------------------------------------------------------------
> Total:                 165219     165218     4656       5523788      5523532
> ============================================================================
> 
> Heap statistics
>         size       alloc        free        diff
> ================================================
>            3           6           0           6
>            4          47          17          30
>            8         106           0         106
>           12      340941      340913          28
>           16       36781         327       36454
>           17          12          10           2
>           18         308         299           9
>           19         356         348           8
>           20        3059        3048          11
>           21        2212        2201          11
>           22        2166        2156          10
>           23          89          74          15
>           24        4121        4037          84
>           25          89          80           9
>           26          55          52           3
>           27           5           4           1
>           28        1362         600         762
>           29          12          11           1
>           30          24          17           7
>           31          21          18           3
>           32         110           1         109
>           33           1           0           1
>           34           3           2           1
>           35           4           2           2
>           36       64759           0       64759
>           38           1           0           1
>           39           1           0           1
>           40       66108        2027       64081
>           43           3           0           3
>           44         305          17         288
>           45           3           0           3
>           46           1           0           1
>           47          18          15           3
>           48           8           6           2
>           49           1           0           1
>           50           1           0           1
>           51           2           0           2
>           52         368         363           5
>           53           3           0           3
>           55           4           0           4
>           56          37          34           3
>           57           1           0           1
>           59           2           0           2
>           60          78          69           9
>           62           3           2           1
>           64       66134        2399       63735
>           66           2           0           2
>           67           1           0           1
>           68          15          14           1
>           69           1           0           1
>           71          16          15           1
>           72          14           8           6
>           76          19           0          19
>           80          74          11          63
>           84           1           0           1
>           86           1           0           1
>           88          14           0          14
>           92          44           0          44
>          108           0           1          -1
>          112           3           0           3
>          128        2254        2007         247
>          140           0          10         -10
>          200          39          35           4
>          204           0           1          -1
>          236           0           1          -1
>          256          45          13          32
>          320           0           1          -1
>          400           1           0           1
>          404           9           8           1
>          744           5           0           5
>         1228           1           0           1
>         4000         280         279           1
>        10023         597         591           6
> ------------------------------------------------
> Total:          82633248    71658677    10974571
> ================================================
> 
> > To tell more about the problem, I need your Event.h and Event.cxx files
> > and also all the classes referenced by this class.
> 
> I hope everything needed is in the attached tar file.
> 
> Thanks,
> 
> Michael
> 
>   --------------------------------------------------------------------------------
> 
>                       Name: event.tar
>    event.tar          Type: Unix Tape Archive (APPLICATION/x-tar)
>                   Encoding: BASE64
>                Description: tar file



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