Add object memory leak

Yesterday it was found that standard lamps don’t sometimes light added objects at all. http://blenderartists.org/forum/showthread.php?t=107213

Then there’s this add object bug I found some time ago where ghost, rigid body and no sleeping buttons have no effect on added objects:
http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=11&t=997&sid=1a60b860850343b9b93dda5a0ac5e7ca

Okay, here’s today’s add object problem :
Every time a new object is added with add object actuator it takes some memory (even though it’s only a few KBs), but that memory is not freed when the object is deleted. I made a quick test where a new object is continually added and then instantly deleted. After running the test for about 8 minutes memory usage had doubled from 20 MB to 40 MB. That means approx. 2,5 MB per minute. So, after an hour the game would take about 150 MB. :frowning:

Couple of days ago Vasil found there’s also memory leak in scene restart.
http://blenderartists.org/forum/showthread.php?t=107138

Small sensor/property bugs are one thing, but memory leaks…I don’t think I can live with those.

You should PM erwin and ask him to place this issue on top of the priority list for the next release. I’m sure he would, since memory leaks are a major issue.

It’s definitely something that would keep me from starting a bigger project in the BGE. Because with memory leaks…why bother.

Shouldn’t there be a sticky bug thread so that developers could be informed of them more easily or should we just use the Blender bug tracker? I see that the problem with bug tracker is that there isn’t categories so it’s bit difficult for GE developers to hunt high priority GE bugs from there.

The memory leaks may or may not would’ve been fixed already have they been found long ago, I’d see about the bug tracker, or you could PM Erwin or MalCanDo.

did you have any response for that ?

Memory leaks have existed in blender for years. It leaked in versions 2.40, 2.41, 2.42a, 2.43, 2.44, 2.45. It could be in even older versions too, I just haven’t tested them. I found this awhile back, along with a few other, but most people didn’t seen this as a problem because most blender games aren’t that big.

No I didn’t.

There’s also the set scene memory leak which is propably the worst of all. I know it has been discussed before, but not everybody knows about it. Every instance of a created scene stays in the memory even if you only switch back and forth between two scenes. For example you have two scenes which both take 100 MB of memory. After you have switched scenes ten times your game will take over 1 GB of memory.

Is there a way to fix the scene memory leak? How do you avoid this…

Does this leak occur with an overlay scene too?

so it’s nearly impossible to do a big scale game with the current game engine ?

I don’t think there’s a way around this. Just don’t change scenes more than couple of times if your game is large.

Overlay scenes propably act the same way. Every scene seems to stay in the memory no matter what you do. You can test it yourself: invoke the task manager (press ctrl-alt-del) and change scenes while monitoring Blender memory usage at the same time.

I have a scene with about 400 000 polys and 40 ai cars + one player car. It runs at 40 fps. The irony is that I can’t change scene even once since one instance of the scene takes about 800 MB (Blender loads all the stuff in the scene at once).

> [I]so it's nearly impossible to do a big scale game with the current game engine ? [/I]

No, you can still make large games in blender. I fould two ways to get around this bug.

    1. After you run a few levels have your game “auto restart”. Saving any extra data, then closing and reopening your game.
    1. You can edit the source code and use the dump() comand after each scene. This requires some C knowledge though.

-do you mean using a sae/load script and use the open/close game actuator? nice idea :stuck_out_tongue:
-second option looks a bit tricky to me… :S

  1. That’s great idea, although implementing it means some extra work (save/load script).

  2. So you know how to fix this leak? Have you tried it yourself? Could you add your fix to the official release or at least provide a patch? Also, do you think the same command could be used to fix the end object actuator memory leak (see the first post)?

  1. That’s great idea, although implementing it means some extra work (save/load script).

-do you mean using a sae/load script and use the open/close game actuator? nice idea :stuck_out_tongue:

Yea, that’s what I mean. But instead of saving the whole scene, only save important values and the NEXT scene’s name.

So you know how to fix this leak? Have you tried it yourself?

Yes, I know how to fix it, but I am still learning C/C++. Erwin could fix it faster than I could, but if he doesn’t, I could do it.

It’s been nearly a month since Erwin last visited these forums; I guess he’s busy with his physics engine. So if you know how to do it maybe you could make at least a temporary patch. That would be very useful, 10x more important than some fancy shader (no offense to shader makers, myself included ;)). You can make a good game without shaders, but you can’t make (big) games at all when there’s memory leaks.

Are you going to make a patch?

Yes, I know how to fix it, but I am still learning C/C++. Erwin could fix it faster than I could, but if he doesn’t, I could do it.

Goody, so this will mean we have another GE developer? This is great.