Skip to content

Unconstrained RAM consumption increase with time due to an incomplete GateCoincidenceDigi destruction #764

@vayeroshenko

Description

@vayeroshenko

Dear GATE developers,

I've been running a PET simulation (with root output) using following stack:
Gate v9.4.1
Geant4 v11.2.2
ROOT v6.32.06
on Ubuntu 24.04.4 LTS

I stumble upon an issue that when I want to let my simulation run for a long time it consumes all the RAM and swap. Testing showed that the RAM consumption rises linearly with time and can reach >30 GB from a single thread, so that's why I call it "unconstrained".
I started investigating and I found out that it something creates a single anonymous page in RAM which just grows in size.
It stays the same if I remove any outputs, and only stops reproducing when I turn off digitisation.
Typical memory leak diagnostic tools don't see any problem, so I started printing out number of created instances of GateDigi minus number of destructed, and it showed me that this number slowly increases with time.

I am not an expert in Gate code, but I found a single-line fix that stops this behaviour from appearing. Now my Gate simulation with ROOT output consumes constant 282MB of RAM per process.
It seems to be related to the GateCoincidenceDigi destructor. I suppose, it does not always cleans the memory properly.

Here is my fix
source/digits_hits/include/GateCoincidenceDigi.hh (l37)

// inline ~GateCoincidenceDigi() {};	
inline ~GateCoincidenceDigi() {for (auto *d : *this) delete d; clear();};

I cannot know if it is the only place with leakage, but it saved my simulation. I thank you for looking into this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions