Memory use, huge problem for large games on mobile

Discussion and feedback on Construct 2

Post » Sun Mar 03, 2013 11:49 pm

I've run into a major problem with the C2 version of loot pursuit it takes up too much memory. After my iPhone 4S runs out of memory, the frame rate utterly plummets to about 2-3 frames per second. I've confirmed that it's a memory problem because deleting animations and textures is enough to fix it and send the fps back to 60. It's also only happening on my iPhone 4S, which has 512 MB of RAM, and doesn't happen on my iPad, which has one gigabyte of RAM. It's also crashing cocoonjs.

The game doesn't even have anywhere near the amount of animations and graphics that it's going to have, and I haven't even started on sound effects and music yet. This isn't a matter of not taking in cosiderations of designing for mobile - it's a matter of keeping the entire entire game in memory at once when only a part of it is needed.

I know webGL has memory management, but that's useless for mobile because they don't support it yet. Also, isn't that only for VRAM? Doesn't everything still need to be in RAM?

My question is, will there ever be some way of managing memory better, or is this something html5 simply doesn't have the capability to do? Will cocoonjs's eventual implementation of memory management fix this problem (as mentioned, it's currently crashing cocoonjs)? This is an essential feature for larger games like mine. Because if there isn't some way for this to be implemented there's no way larger games like loot pursuit can be delivered on mobile, even though aside from using too much memory it runs fine. It might even be a problem for desktop games as well, that's a lot of memory use! :(
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon Mar 04, 2013 12:14 am

I never knew you were trying to bring Loot Pursuit to mobile - good luck!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Mar 04, 2013 12:17 am

RAM use is typically small compared to VRAM use. In the browser, if it supports WebGL, we manage memory layout-by-layout ourselves. If it doesn't, it's up to the browser to manage it - and if Safari isn't doing a good job you need to ask Apple to fix it, since there's not much else we can do... As for CocoonJS, we have supported memory management in our code for a long time now, @Ludei just need to add some functions and our engine will detect it and automatically start using it. However Ludei haven't made any progress on this for a while, despite its absolutely crucial importance - the largest games are often the best, and not having memory management rules out the largest and best games. So please ask Ludei to hurry up!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Mar 04, 2013 12:54 am

Do you think can you manage creating and destroying objects while is on-screen?

I don't know it may work using Array to memorize every objects each layout in C2 editor, then destroy everything are not on screen in runtime.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Mon Mar 04, 2013 1:23 am

@Ashley - Thanks for the info, I'll definitely mention it to ludei. What about audio, though? I imagine that could use a lot of memory. Does c2 unload audio, and if so, what causes it to do so, and how does it know what to unload? Or is that up to the browser makers/ludei as well?

I remember at one point, perhaps in a blog or update log, you mentioned the possibility of writing a blog detailing exactly how the memory management works - I would definitely like to know all the details if you're still thinking about writing about it, and I think it would be quite useful to others making large games as well.

@squiddster - thanks!

@Joannesalfa - I'm already basically doing that. I'm not keeping instances of all objects in the project in a layout at the same time, it's a problem with the way browsers manage memory they currently try to store everything in memory at once even though they don't need to.Arima2013-03-04 01:27:08
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Mon Mar 04, 2013 1:25 am

Is it possible to get a VRAM expression for Construct 2 like in Classic?
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Mon Mar 04, 2013 4:52 am

@Ludei @Ashley My current game uses a lot of different images (not animated) that, for simplicity of logic, are stored within one object as animations frames and referenced by an array. I should be able to load the images by URL and save RAM (dumping the old images would do this, I assume).

The fact that ajax still isn't working in cocoon means I can't load by URL. I believe ajax is needed to do this. Either way, load by URL and file imports are not working in cocoon.

Please could you put this up high on your current to do list? I am starting to experience RAM issues and have plans to significantly expand the game further. In fact, it's expanding the game with in-app purchases that will allow me to monetise my app!

Many Thanks
B
29
S
8
G
4
Posts: 61
Reputation: 6,205

Post » Mon Mar 04, 2013 5:18 am

Last I heard, wasn't CocoonJS also experienting with WebGL support? If that's successful, would C2's memory management already be used?

B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Tue Mar 05, 2013 4:58 pm

@Arima
You can see memory warning in the xcode as well when you build the app and you are connected to the device.

We had different problems with the last game Turmoil Deluxe. The only fix was to redraw the art smaller etc. sound is a nightmare i can tell you that.

@Nathan

I think thats possible with JSON and a extension from CocoonJs
And other solution would be to write files into temp or documents folder of the device and load it
B
5
S
1
Posts: 49
Reputation: 1,148

Post » Tue Mar 05, 2013 5:08 pm

I've been in touch with Ludei since this post. They say they're working on memory management features now. Good news and hopefully this will fix large projects!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests