Adding Armature Performance Decrease

While working on my current project, I noticed that I was getting decreasing performance the longer I ran the game. I was able to narrow it down to a particle system that added many armature objects. These armatures are quickly ended, but as the game continued to run, the time it took to add each armature increased.

I’ve put together a very simple file to demonstrate the issue:
adding_armature_performance.blend (78.1 KB)

It just contains an empty that adds 10 single-bone armature objects every frame. The armatures have no actions and are immediately removed. Note that the logic usage starts out low but continues to steadily increase to unacceptably high levels (though it will occasionally drop down slightly before increasing again). Also note that if you stop and start the game engine again, the logic usage will immediately jump to the same level again before continuing to increase. This performance drop does not occur when adding normal objects as you can see by changing the added object to the cube

I don’t know exactly how the BGE handles armature objects differently from normal objects that causes this, but it seems to be something memory related since the performance drop remains until you completely close and reopen Blender. I plan on submitting a bug report, but just wanted verify that it’s not just happening on my machine first.

EDIT: Just did some additional testing. The problem seems to occur from version 2.71 and up. It does not occur on 2.70.

EDIT2: I went ahead and submitted a bug report to the tracker here.

EDIT3: Fix submitted here.

Hum… Memory leak?

It’s possible that there may be a memory leak here as well, but that alone shouldn’t be causing such a drastic drop in performance.

It’s the way you have your script written. Adding cubes the same way as the armatures has the same performance drop, it’s just not as drastic.
I played with this for a while and didn’t get the persistent performance drop you’re talking about. I’m using Blender 2.75.

Try adding one object at a time, instead of using a for loop and trying to add 10 at a time.

Ending the object on the same call that it’s created is going to effectively give you nothing in return. What’s the reason for that?

Why do your particles need armatures?

Really? I tested it with adding cubes and even increased the number of objects added per frame to 1000. While the logic time was obviously very high, there was no noticeable increase even after running the engine for 5+ minutes. I’m using 2.75 c6b042b

For me when running it while adding 10 armatures per frame, the logic time goes from ~1ms per frame to more than 100ms per frame in under 10 seconds.

The only reason the loop is there is to amplify the decrease in performance. The performance drop still occurs when adding 1 armature at a time, it just takes 10 times as long to happen and is 10 times less noticeable since the performance drop happens on the calls to scene.addObject() when the added object is an armature.

This is a simplified .blend file to demonstrate the problem. I of course don’t remove the objects immediately in my project, but the problem still occurs.

“Particle system” was a simplification of what I was actually doing, but if you must know it’s because I need them to play blended actions. Action blending does not work for normal objects.

EDIT: Are you running Windows btw? I’m running Windows 7 64-bit. It’s possible that this is an OS specific problem.

windows 7, 2.75 here I have the same problem, the logic spikes persisted even when I reenter the game after multiple exits, I also found that it will persist even after I had deleted the original armature and replace it with a new one with a new and different name

Lastly, the logic are still skyrocketing even when I had instead added the cube as parent with the armature as child to the scene but nothing happens when the I swap parent-child status

Thanks panzergame for the quick fix.