[python-wrapper] OutOfMemoryError GC Overhead limit exceeded

Dear orekit community,

I have been trying to use the orekit python-wrapper in a python script to propagate multiple orbits (thousands) using the NumericalPropagator.

The results of the propagation is then used for something else within the python code. The whole code works fine for a few propagations + post-processing at a time.

My code is pretty straight forward and was taken from an example in the orekit python-wrapper tutorial. I have just added a loop around it.

However for some reason, after several iterations I get from the JVM:

pv = [propagator.propagate(tt).getPVCoordinates() for tt in t] ## PV is the resulting Satellite position vector
orekit.JavaError: <super: <class ‘JavaError’>, >
Java stacktrace:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.hipparchus.geometry.euclidean.threed.Vector3D.negate(Vector3D.java:394)
at org.orekit.utils.AngularCoordinates.revert(AngularCoordinates.java:428)
at org.orekit.frames.Transform.getInverse(Transform.java:454)
at org.orekit.frames.Frame.getTransformTo(Frame.java:267)
at org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel.acceleration(HolmesFeatherstoneAttractionModel.java:1037)
at org.orekit.forces.ForceModel.addContribution(ForceModel.java:90)
at org.orekit.propagation.numerical.NumericalPropagator$Main.computeDerivatives(NumericalPropagator.java:502)
at org.orekit.propagation.integration.AbstractIntegratedPropagator$ConvertedMainStateEquations.computeDerivatives(AbstractIntegratedPropagator.java:672)
at org.hipparchus.ode.ExpandableODE.computeDerivatives(ExpandableODE.java:134)
at org.hipparchus.ode.AbstractIntegrator.computeDerivatives(AbstractIntegrator.java:265)
at org.hipparchus.ode.nonstiff.EmbeddedRungeKuttaIntegrator.integrate(EmbeddedRungeKuttaIntegrator.java:257)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:464)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:410)
at org.orekit.propagation.integration.AbstractIntegratedPropagator.propagate(AbstractIntegratedPropagator.java:393)

I have tried moving the orekit.initVM in and out of the loop besides using some memory options but that error was still thrown at some point.

Would you know if it might be related to memory issue within the python code or is there something happening in the orekit-wrapper? Is there a function I should use to force re-initialize the JVM at the end of the loop?

Thanks a lot for any tips you may have!
Cheers.

Hi,

It looks like the java VM runs out of memory. There are settings for memory allocation to the JVM, as well as sending arguments to it in the initVM() function. See section “JCC’s runtime API functions” at:

https://lucene.apache.org/pylucene/jcc/features.html

You should and need only to call initVM() once.

Note also that you are creating an array of objects, which means that there will be java objects stored in the JVM as long as they are referenced.

Regards

Hi,

Thanks for your answer. I have tried using the memory allocation argument but the same problem did occur as well.
The object created are normally re-initialized at every iteration, so unless there is a memory leak somewhere I don’t understand why the JVM is complaining after N iterations.
Should I maybe set all my reference to None at the end of 1 iteration?

Thanks.

Hi,

I would suggest you try a normal for loop instead of a list comprehension if you only need the final states.

As the list comprehension stores all your PVCoordinate objects in a list it will fill memory over time.

Regards
/Petrus

Hi,

I do need the PVCoordinate at every step unfortunately. I ‘only’ have about 100k PVCoordinates stored however at every iteration.

Now I would understand that I have a problem if after N iteration these are all kept in memory in the JVM.

If that is the case and the JVM stores the references internally, is there a way to force the GC to free the memory allocation?

Thanks again for your suggestion :slight_smile:

Hi,

Not sure it should be a problem, but you could try to store the coordinates as normal python numbers in an array and not as orekit objects in an array. Like a for loop and then .getX, getY etc for the actual coordinates.

Regards