Garbage collector slowing down game

Discussion and feedback on Construct 2

Post » Sun Jun 24, 2012 10:06 am

a quick question @Ashley as he's the main brain of this operation :)
when running a phonegap C2 export through eclipse, in logcat i get garbage collector logs almost every second. we all know that gc uses quite a bunch of processor cycles. do you think it's woth my time to make something like sprite pooling in my C2 game? ie. don't destroy bullets, instead hide them / make them inactive and when needed don't create them, but set their position / active / visible again?
thanks in advance :)
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Jun 24, 2012 10:22 am

Just a curiosity... How do you recognize garbage collector logs in logcat? I set it to Verbose and still don't find them.
B
11
S
3
Posts: 224
Reputation: 2,028

Post » Sun Jun 24, 2012 12:01 pm

GC Concurrent freed something something % :)
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Jun 24, 2012 6:52 pm

Ashley has already taken steps to reduce GC through instance reuse and other methods, so C2 does it automatically for you! http://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jun 24, 2012 9:01 pm

yea, i meant, C2 cant know that im gonna be creating 10 bullets every second, so the real question was does it make sense to create like 50 bullets at start of level and like described reuse them?
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Sun Jun 24, 2012 9:56 pm

I doubt it, but I guess that's a question for Ashley, as I don't know the specifics.

You could always try a test and see if it improves things, it shouldn't be too hard to implement.

Honestly though, I'm not sure you should bother. Even a .capx with 1 sprite that moves around with 8 direction behavior stutters a bit on my machine (that can play most modern games no problem) in FF, chrome and IE. I have a game I'm making that cyles through like a hundred lasers a second and it doesn't stutter any more than the 1 sprite 8 direction test did. You're probably going to get them no matter what you do until browsers improve.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jun 24, 2012 11:15 pm

Construct 2 automatically recycles objects (and other items) in its engine already. There is nothing to gain by doing this yourself in events.

Garbage collection is a normal and expected process - it is only a problem when it pauses for a long time (e.g. 100ms+). In fact, lots of regular small garbage collections are usually good news, because many tiny pauses make for better playability than a few long pauses.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,574

Post » Mon Jun 25, 2012 1:06 pm

good, great, got it.
thanks
B
81
S
50
G
10
Posts: 555
Reputation: 13,009


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 18 guests