-
Notifications
You must be signed in to change notification settings - Fork 69
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 management in BreakingCondition #493
Comments
Hi @CaratheodoryRR Edit:
|
A hacky solution would of course be to cut the simulation into smaller pieces (reducing the number of Candidates per run) so that the memory is large enough. If anyone knows the difference of the memory handling between Observers and AbstractCondition it might help to understand why one is working and the other not. |
Did you test it? Because I already do that in my program and I am facing the same problem. The RAM usage keeps growing monotonically over time, and the only way to free up memory is terminating the program. PD: I accidentally closed this issue, sorry for that. |
Hey |
Yes, the RAM will still grow over time, but if the simulation finishes before the RAM is full the results should be fine, shouldn't they? |
Hello @JulienDoerner, thanks to you and @lukasmerten for your replies. This observer-based approach solved my memory issue. I also added some code for the minimum energy condition as an observer feature, and it works! This memory problem haunted me for a couple of months and it prevented me from making progress in my research. I understand this is a temporary solution though, so any updates regarding the memory handling of the |
I reproduced the bug by running a simpler version only with c++
The memory issue seems not be related to the SWIG interface but rather the C++ module handling. |
I traced the issue down to the Line 34 in 61a6257
By default the key is "Rejected" but there is no One can solve the issue by setting the
I would suggest to add a default value for the flag based on the module name. This should solve the problem for all abstractConditions |
For context, I ran several simulations inside a loop, varying mass composition to see the energy spectrum at the Earth. I noticed that the RAM consumption was exceedingly high after some time. Further inspection revealed that RAM usage was steadily increasing during my 3D simulations, and the only way to free up that memory was by closing the program.
After debugging, I think the problem is related to the breaking conditions I used, which are
MinimimEnergy
andMaximumTrajectoryLength
. I came up with a minimum reproducible example by modifying this 1D example on the documentation.To Reproduce
In this example, I noticed two things. First, the
Observer
object correctly manages inactive particles, since running this simulation as it is didn't increase my RAM usage significantly, as shown in the followinghtop
command output:But if I trigger the breaking condition by changing the source emission direction to
Vector3d(1, 0, 0)
, the RAM usage increases and there is no obvious way for me to decrease it:Expected behavior
Based on what I showed earlier, I expected the breaking conditions to behave similarly to the observer object. That is, freeing up
particles once they meet the condition, thus making them inactive.
Additional context
This is a problem for me because, at some point, I am using
ParticleCollector
to rerun simulations from saved files, but after some time the outputs of these extra simulations are like this:Which gave me the hint that this was a memory-related problem.
The text was updated successfully, but these errors were encountered: