Optimization and memory leaks

Get help using Construct 2

Post » Thu Aug 02, 2012 8:19 am

Sorry for the many posts, especially questions..! But I need some guidance here. I'll try my best to contribute back to the community soon with some scirra exclusive graphics tutorials, but for now heres my question..

My game works fine, quite fast on my computers at first, but in a matter of minutes (10-20mins) the game starts lagging quite badly and this happens even without touching the game.

So I'm thinking its to do with some of my looping/timed events are causing memory leaks.

All I can think of is if I'm creating objects and not clearing it but this shouldn't be the case as I've looked through it.. Are there any other good practices I should be following to ensure this doesn't happen?

You can try my game HERE and tell me if it happens to you too.

Thank you in advance!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Thu Aug 02, 2012 8:44 am

The manual articles : Best practices and performance tips as well as this blog article about optimisation should be worth reading. (I recommend to actually read the whole manual at least once for anything C2 related)

To help you though, it would be better if you would post the capx of your project, so we can check the code directly.
Hard to say anything otherwise.
Possibly as you say, loops creating objects when it shouldn't, but no code, no way to tell for sure.

As far as memory leak goes it is unlikely, I've tried your project, and when I shut it down, I got back the same amount of RAM I had before launching it.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Aug 02, 2012 8:48 am

Thanks for ruining my computer


j/k

Biggest Looping can cause memory leaks, also Physic can consume CPU a lot. I tried it game, i found no lag points.

If you see the creating object with every ticks it can generate multiple objects in perfect position, make sure to use "trigger once" condition.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Thu Aug 02, 2012 8:51 am

Hmm, but does it start lagging for you after awhile?
I've uploaded the capx HERE :)

Thanks for the offer :) would be awesome if you could help!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Thu Aug 02, 2012 8:55 am

@Joannesalfa Woah, thanks for that, I didn't even know the existance of that condition.. I've been using booleans to check if its been triggered before! haha!

Also, I've just turned off pixel rounding, and though it has noticeable differences, it just sped up the game a lot!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Thu Aug 02, 2012 8:58 am

The link you posted is not correct apparently.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Aug 02, 2012 9:03 am

I get progressively slower level to level, not really noticeable until level 6, then level 7 it starts to show little stutters in the fired sprite every second or so. At level 9 it was getting too slow to be fun. (which it is up until then.) I just read some of Ashley's post on Garbage collection yesterday, which I now wonder if I should have read more. because it seems like garbage collection could be a factor.

found it: http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript
B
201
S
52
G
30
Posts: 897
Reputation: 36,621

Post » Thu Aug 02, 2012 9:13 am

[QUOTE=Kyatric] The link you posted is not correct apparently.[/QUOTE]

Opps! my bad, here it is
http://www.shudapanda.serw5.com/ShuDaPandaSRC.capx
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Thu Aug 02, 2012 2:59 pm

There should be nothing in the engine that could degrade performance over time, unless you are doing something like continually creating objects and not destroying them. That's then a problem with your events rather than any issue with the Construct 2 runtime.

Try putting a text object on-screen with the object count and keep an eye on it - make sure it's not increasing constantly throughout the game.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Aug 02, 2012 3:22 pm

Speaking of counts...
Is it possible to introduce (or maybe it already exists) a statistics view in Construct 2 projects ? Like how many events/actions, instances (in layout), object declarations, etc, etc, in order to have a global vision I mean :)
B
40
S
9
G
5
Posts: 127
Reputation: 6,609

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 17 guests