Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory consumption due to G4TouchableHandle in RMGOpticalDetectorHit #205

Open
EricMEsch opened this issue Dec 20, 2024 · 2 comments · May be fixed by #206
Open

Memory consumption due to G4TouchableHandle in RMGOpticalDetectorHit #205

EricMEsch opened this issue Dec 20, 2024 · 2 comments · May be fixed by #206
Labels
performance Memory/CPU consumption

Comments

@EricMEsch
Copy link
Contributor

I have tried to rerun my full cosmogenic simulations for the water tank (e.g. Simulate 1e7 muons and output all detector responses for every Ge77 event, including PMTs) and i suddenly started having memory issues. I have not exactly pinned it down, but i am 99% sure it has to be due to commit f0d40db, that added a G4TouchableHandle field to RMGOpticalDetectorHit.

Here are the heaptrack analytics of the run when i go to commit f0d40db (I ran out of memory before finishing the run):
After

And here is it if i go back to 172f1a1:
Before

As the G4TouchableHandle there is only required for the Draw() function, which has no use in batch mode, is it possible to hide this in batch mode? Or just use the pointer instead of the actual object?

@ManuelHu
Copy link
Collaborator

ManuelHu commented Dec 20, 2024

It is not useful to store a pointer to a G4TouchableHandle - it is already a "handle", i.e. a pointer to the underlying refcounted step point data (see G4ReferenceCountedHandle.hh)
The overhead of the handle itself should be minimal, but without storing the handle, the step data would not be kept around by the Geant4 core.

but we could make the storage optional, please test #206 if it fixes the high memory consumption.

@gipert
Copy link
Member

gipert commented Dec 20, 2024

Good catch @EricMEsch!

@gipert gipert added the performance Memory/CPU consumption label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Memory/CPU consumption
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants