ode4j icon indicating copy to clipboard operation
ode4j copied to clipboard

Garbage collection - step()

Open tzaeschke opened this issue 8 years ago • 3 comments

As mentioned in issue #35, ode4j appears to allocate significant amounts of memory in some situations/systems ("3-4 MB/s").

The problem may be in the stepper which allocates large arrays for the solver during each step.

A solution could involve array pooling.

tzaeschke avatar Oct 06 '15 11:10 tzaeschke

I implemented an experimental hack which can be enabled with: DxQuickStep.REUSE_OBJECTS = true;

This reuses a number of objects, including the large collision used in the stepper.

Could someone have a look whether it improves the situation on Android? We could apply the same approach to other places in the code.

tzaeschke avatar Oct 29 '15 22:10 tzaeschke

It looks like some improvement has been recently made in ODE too - see https://bitbucket.org/odedevs/ode/commits/506a3b3b93c2ef0da3e5030bf12e408aef59c2cd

ppiastucki avatar Dec 08 '15 08:12 ppiastucki

Yes, they seem to avoid allocating Ad, even if that is much smaller than other matrices (iMJ is 12 times bigger). What I did in this patch is really just a hack and should definitely be extended to the matrix solver as well. I also looked a few days ago at porting ODE changes to ode4j. But quickstep has changed considerably, so I suppose I need a week off for that. Maybe over the upcoming holidays.

Has anyone seen a measurably reduced GC load from my initial patch?

tzaeschke avatar Dec 08 '15 21:12 tzaeschke