Closed haji-ali closed 4 years ago
Hi Abdul,
The problem is that you are calling loadStandardSpiceKernels inside your loop. The Spice Kernels that are loaded when calling this function are not unloaded at the end of the GetOrbit function, and at some point Spice complains that too many kernels are loaded. If you move the loadStandardSpiceKernels function call to your main function, before the for loop, this issue should go away,
Best,
Dominic
Hello Dominic,
Thanks! In my actual code, I do the computations in separate threads. I was trying to avoid the thread safety issues of #541 by loading separate kernels for every computation. I am worried that loading a single kernel for all computations (done in parallel) could lead to problems.
As far as I can see, there is no way to "unload" the spice kernels in tudat to avoid NOMOREROOM
issues, is that correct?
Also, I now realize that this is a separate issue, the valgrind output shows a memory leak is from an allocation in tudat::simulation_setup::createBodies
.
Hi Abdul,
Indeed, thread safety is an issue. Spice is inherently thread-unsafe, and there is a small (?) memory leak from 'createBodies'.
The best way to parallelize is:
Best,
Dominic
I see. Thanks! I am guessing that the names in bodyMap
have to be unique across all threads.
I also found clearSpiceKernels
which frees up the spice kernels.
What do mean exactly with:
I am guessing that the names in bodyMap have to be unique across all threads.
You can have a separate "Earth" body in each thread (and probably will)
I meant the bodies inside bodyMap
like Asterix
. I am not sure what the internal implementation is, but the name of the object seems to be used as a way to reference that object. I assume if I have several threads doing similar computation, I would have to have an Earth body in each, but the names of the bodies to propagate should be different.
If you're multithreading, you're going to have to create a completely separate and independent body map for each thread. So, you must have N body maps, each of which will probably start out identical (with an Earth, Asterix, etc. entry)
Hello,
I am trying to run a Monte Carlo simulation of
SingleSatellitePropagator
. I modified the code a little to run a completely independent computation for different initial conditions of position and velocity (I know I can reuse parts of the computations, but I want to start simple). After every single computation, I make sure that all objects that were allocated by tudat are freed (as they should be when objects and shared_pointers are deleted from the stack).After running more than
5300
calculations, I get the errorI am not sure which why files are lingering from
SPICE
after all tudat object are freed.Possibly related, running
valgrind
onapplication_SingleSatellitePropagator
, I get the following leakBoth of these problems are preventing me from running many Monte Carlo simulations.
Any help is appreciated.
PS: Here is some simple code that shows this issue