Mystery: My savefile gets crazy big for not apparent reason.

Discussion and feedback on Construct 2

Post » Mon Mar 09, 2015 1:56 am

Hello all,

I have a problem with the savefile of my game but I don't know what it is and where to start my investigation. Maybe one of you will have a suggestion?

The problem:

My game's savefile gets too big over time, and reach the browser's file size limit of 5 MB. The thing is: my savefile is normally only 20-50KB which is way under the 5000KB limit. But over time, the savefile gets bigger and bigger.

I should specify that my game is an idle game (think Cookie Clicker), so it is meant to be left open for days and even month for some of my players. It is also saved and reloaded often hundreds of times. My players with the issue have had the game open for 1-2 months before the savefile reached above 5000KB.

What I tried so far:

1) I asked my player to send me his savefile, which I loaded in the game while running Construct's debugger. I can see in the debugger that everything seems normal. I don't see anything that would indicate a memory leak. I was expecting to see an object with billions of duplicates, but no. There isn't a layout with more than 100 objects in it.

2) I added the behavior "don't save" to most objects that didn't required it (UI elements for example). That didn't help.

3) I tried to create a new empty project where I create and destroy hundreds of objects every tick, and compared the savefile. I could NOT reproduce my issue this way (the savefile remained clean).

The savefile
He's the affected savefile:

Looking at it, I can see which section is taking 99% of the space. It starts like this:

Code: Select all

It's followed by about 1500 pages of the same kind of data (yeah, just for fun I tried to print it to see how many pages I would get!) :)

As you can see, it starts with "collmemory" which I tried to search on Google and Construct forums, but could not find anything about it. Do you know what that is? Do you know what is this giant list of numbers?

Any hint would be welcome. Thanks!
Last edited by narFsnw on Tue Mar 10, 2015 2:56 am, edited 3 times in total.
Posts: 85
Reputation: 1,473

Post » Mon Mar 09, 2015 3:22 am

After more test, I found out that "collmemory" seems related with the "On collision with..." event. In a new empty project, I start to see "collmemory" in the savefile only when I add "On collision with" events. I assume that "collmemory" would mean "collision memory"?

I could see how this could lead to my big savefile problem. In my game, lots of sprites are created, then destroyed when they collide with another object. I'm just wondering why data is saved in these cases.

Any hint?
Last edited by narFsnw on Tue Mar 10, 2015 2:57 am, edited 1 time in total.
Posts: 85
Reputation: 1,473

Post » Tue Mar 10, 2015 2:46 am

I was able to isolate the problem in a small capx file.

This capx create a lots of orange sprites every ticks, and moves them inside a green box. On collision with the green box, the orange sprites are destroyed.

That by itself isn't enough to reproduce the issue. You need to first save (using the debugger) and load that savefile (using the debugger). Only by loading the savefile will you start to experiment the issue.

When you look at the javascript console, you can see the size of the savefile. It quickly gets very big, even if all the objects have been deleted.

2015-03-09 22_28_58-Greenshot.png

Steps to reproduce:
1. Open the capx using Construct's debugger.
2. Open the browser's javascript console.
3. Save using the debugger. Notice the savefile's size in the console (about 1 KB).
4. Activate the sprite creation by checking the checkbox.
5. Leave it checked for about 5 seconds, then turn it off.
6. Save again using the debugger. Notice that the issue didn't occurred (savefile is still about 1 KB).
7. Click "Load" in the debugger to load that savefile. (that's the important step!)
8. Activate the sprite creation again.
9. Turn it off after about 5 seconds.
10. Save using the debugger.
11. Observe the issue : The savefile is now 100 times larger!

So... what do I do with this? Is it a bug in Construct?

What is it saving exactly that makes the savefile so large? Looking at what is inside "collmemory", it's just a few numbers for each sprite, but if they don't get removed when the sprites are deleted, then the savefile gets very huge over time. That's kind of a memory leak, right?

Should I fill an official bug?
You do not have the required permissions to view the files attached to this post.
Posts: 85
Reputation: 1,473

Post » Tue Mar 10, 2015 3:00 am

are you using the save&load plugin? if so do your objects have the nosave behavior on them?

edit: looks like a bug
Last edited by volkiller730 on Tue Mar 10, 2015 4:48 am, edited 1 time in total.
Posts: 850
Reputation: 6,234

Post » Tue Mar 10, 2015 4:30 am

Confirmed, looks like a bug. Filed a report here:

My best guess is since "on collision" is only triggered once per overlap that is somehow not being cleared, and when loading the id's of everything changes or something like that.
Posts: 5,591
Reputation: 85,520

Post » Tue Mar 10, 2015 1:13 pm

Thanks R0J0hound! Thanks volkiller730! I was really starting to worry here. Thanks!
Posts: 85
Reputation: 1,473

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 1 guest