Hello everyone,
I’ve written a bark beetle model in NetLogo and am currently running simulations on a Linux server using BehaviorSpace in headless NetLogo with 128GB of RAM and 24 cores. A single simulation run can consume up to 15-20GB of RAM, as in extreme cases, the model creates up to 20 million individual beetles.
For about a week now, I’ve been trying to find solutions for the following issue, and I’m hoping someone here might be able to help me out. It took me quite a while to figure out that the garbage collector (GC) either wasn’t functioning at all or was only working to a very limited extent without specific edits to the headless configuration. I’ve since added the following lines to the JVM options, which has brought some improvement:
-XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:InitiatingHeapOccupancyPercent=40
I’ve also analyzed the GC logs, and it seems to be working.
However, the problem persists that RAM usage continues to build up across multiple simulations. Only restarting the JVM (or stopping and restarting the experiment execution) clears the cache. Without doing this, I can end up with something like 120GB of used RAM, even though only the last of, say, five parallel simulations is still running. At this point, the RAM usage should really be down to around 15-20GB.
Has anyone encountered this issue? Do you have any ideas for a fix? My current workaround is to split my experiment into lots of smaller experiments and run them via a shell script so that NetLogo restarts and clears the RAM between experiments. But this is only a partial solution, as I’d like to use the server’s rental time as efficiently as possible.
Any tips or ideas would be greatly appreciated!
Best regards, Joe
Edit: is it somehow possible to run any form of GC in the model code to force JVM to run the GC?