Problem with ridiculous memory usage over time

I’ve been creating a game that, when started up, takes around ~80ish MB of RAM. Now, over time it uses more and more RAM and it doesn’t stop using more. It’s been as high as 3GB and rising. The reason for this seems to be a single integer variable on an object called “counter”. The .blend is attached, so if you could take a look, that’d be great. I hope there’s an easy solution to this, because as of right now this is 100% game-breaking and that makes me kinda sad. (Also, I hear you asking “Why would you copy cookie clicker you evil person!?”, well, just for the fun of it, really. Also this is just supposed to be the currency system of the ACTUAL game which doesn’t exist… yet.)

Here’s the blend: http://www.pasteall.org/blend/24242

My experience with a bug of your description is a memory leak relating to textures. I’m not sure under which circumstances the error occurs, but it’s likely a Blender inherited issue.

I’m not sure it’s related to textures, if I change the variable type on the “counter” object from int to boolean (which breaks the game, but anyway) but leave everything else as is, the memory usage remains steady.

Is that counter used to add objects/replace meshes / load scenes?

It does none of these thing. All it does is to receive messages and to alter properties.

Edit: the counter is a text object (classic texture-based text) and the “Text” property is the integer property that is causing all the troubles it seems.

Ok, I think I figured out that problem. Apparently there are some bizarre interactions going on between a property sensor set to interval mode, a property actuator set to copy mode, and having debug information enabled on the property you’re copying to (this is the logic setup you have on all your “upgrade” objects).

Here’s the simplest blend I could create that replicates the problem.
weird_memory.blend (438 KB)

My best guess as to why this is happening is that the debugging info system is creating a new tracker for the property you are copying to each time the copy property actuator gets activated (though I have no idea how the property interval sensor comes into this). It’ll take some digging in the source code to figure out exactly what causes the issue.

For now, the best solution is probably to either disable the Debug Properties option, turn of debug info on the property you’re copying to, or just don’t run the game for very long when you do have debug mode enabled.

EDIT: I’ve submitted the issue to the bug tracker.

Thanks for looking into the issue, your first solution doesn’t seem to work on my end though. The problem also appears when the game is exported and run as a standalone runtime, so the second solution (to run the game for limited amounts of time) isn’t really an option either.

Apparently having a second property sensor that isn’t set to interval mode causes the same problem to occur regardless of whether debug mode is on or not. You can maybe try separating the logic bricks so that they’re on different objects or changing them slightly.

If that doesn’t work or isn’t possible, I would recommend just using a Python script. It’ll make thing much cleaner any way since some of your object have a huge number of logic bricks that make them very cumbersome to work with.

I have no idea when it comes to Python, but I assume it would be quite simple to transfer the awful setup to code. I’ll see if I can fix it the “easy” way first for now by moving around the logic bricks (which are cumbersome no matter how many of them you have lol, I really wish somebody would create a node alternative to the logic bricks…).