Heap size keeps increasing using physics, help?

Hey, I’ve ran into some fps dropping issues with my game.

I’ve concluded that its related to the generation of projectiles, and most likely is

caused by some kind of memory leak, but I’m unable to figure out what more specificly is causing it.

When having a high fire rate of projectiles (spawning many per second)

this is what happens when I keep firing them.


I’ve been running the profiler to try to figure the heap peaks out but with no success.

I’m thinking it might be related to the physics space not releasing some objects,

as I do not have the issue if I dont attach them to the physics space.

Right now, this is what I do when a collision occurs between a projectile and another object,

alternatively if it has travelled further than its range.

This is from the ProjectileCollider.class handling collisions

The kinetic controller is ProjectileControl.class

proj is the projectile instance (a node)

[java]private void remove() {

if (future != null) {



future = gs.enqueue(new Callable<String>() {


public String call() throws Exception {

// Remove the kinetic control


// Remove collision listener (this)


// Remove projectile with its controls from ps


// Clear the projectile node



// Remove from projectiles node


return “ProjectileCollider(remove)”;




When not attaching to physics space this is the result, with a stable heap.

And no fps drop.



Has either of you run into this problem before, and found a cause of it/solution for it?

Or do either of you have a clue what might be happening?

Remove them not with removeAll() which only removes the first physics control of each spatial but do it with each by hand.

Yea found out, gah.

Fixed now thanks.