Skip to main content
Inspiring
February 19, 2012
Question

Optimize app/ load everything to memory?

  • February 19, 2012
  • 4 replies
  • 2912 views

Everything in my game, e.g. button-effect/ sound-effect runs very smooth the second time they are activated, the first time there's always a bit of lagging.

Is it possible to cache or load the hole app into the memory at once (if it's not done automaticly), or is there anything else to do? The game runs at 50 fps, stable.

This topic has been closed for replies.

4 replies

gronli21Author
Inspiring
February 21, 2012

Thanks a lot Many good tips. It helps me for future projects.

February 20, 2012

good point, don't abuse about memory... although you must have everything you are going to show on the screen previously loaded if you want smooth transitions (of course things you're not going to show unload them), I think up to 60ish 70ish MB is about the limit from my personal experience dealing with different devices. About the device being busy with other apps in background it is something you can't control, you can popup a message to avoid your game crashing saying "there are not enough resources for blah, blah..." you can detect how much resources you have available through a native extension. I had worked fine to me, I got no problems with this at all. I hope it helps.

User Unknow
Legend
February 20, 2012

to avoid your game crashing saying "there are not enough resources for blah, blah..."

In this case your app will recevied negative feedback in app store and will ne not sold anymore =)

Better show message 'Hello, our developer don't want waste time for optimizations so please don't run this app again!'

Note one thing. When you release app to AppStore it's manually tested by App Store developers and if they will see bugs with memory leaks they simple reject your app.

Take a look here http://itunes.apple.com/us/app/id497335117

My binary is 20mb and rest in external folder. It's run very smooth on iPad1 - most slowest iPad )) And this because I make all backgrounds 768x1024 and all mp3s as external fiiles.

Next my book I will make in different way. I will make external all swf files so my binary will contain only swf loaders. This will add additional 50% performance because next book will include also games.

February 20, 2012

Hi! I took a look at the "Puss in boots - interactive book", it looks really nice, quite cool illustrations, well done. Now I know what you mean, "interactive books" are quite different to code comparing with games, some games require far more assets animated on the screen at once, I am currently working in a project called "Traffic Wonder" which the binary is 7MB and the rest of the game 160MB, in some levels I have to compose on the fly up to 14 different layers (background, cars, shadows, lights, tunnels, bridges, etc...) which behave differently depending on touch response, it still runs fine on Amazon Kindle Fire, feel free to download the game, it is at the moment on its last QA stage http://www.trafficwonderapp.com

important thing to mention, a good QA gives you a lot of confidence about your product, so you have no surprises when the game is live, and you probably will never need to show messages like "Hello, our developer doesn't want to waste time..." nor even limiting your program to use low resources otherwise it crashes, that's sad.

my coffe break has finished, have good day everyone.

February 20, 2012

ehhh, hmmm... interesting, the way I solve issues like this is, simply place the assets somewhere hidden on the screen before using them, so by the time they appear on the screen, they are already in memory and ready to be used. does it make any sense?

User Unknow
Legend
February 20, 2012

Do not try to do this.

For example you have game with 3 levels. Each levels about 20 mbs, for example.

So you will have all levels in memory. iOS will generate Memory Warning. There is 4 levels. 0, 1, 2, 3

App with binary more than 45 mb will receive level 2, almost critical ) If someone have opened many apps in background - your app will be crashed immediately.

So, let's back to levels. Your app will be slow as turtle. Solving of this - make each levels as swf file and store it in external files and load it separately. This practice is the best ) Not only for Air but for any iOS developing languages inclduing native objective-c

User Unknow
Legend
February 19, 2012

Don't load at once. iOS better 'eat' small binary app files. So best practice it's write engine that will load addtitional files when you requere it. This will increase your performance twice at least

gronli21Author
Inspiring
February 19, 2012

Ok, thanks. The game is very small and the menu's easy, but I'll keep that in mind for future projects.

Forgot to say that I use Flash CS 5.5 (iOS)

User Unknow
Legend
February 19, 2012

You can have only one button and sound applied to it more than 20mb =)

So Air Runtimes will have 10mb + your sound 20mb + your swf 10 kb )

For example this will invoke lags beacuse your one button will load fast since it is only 10 kb and 20 mb embeded mp3 will load slowly )))

Simple do as me.

1) all files that can be exported as separately (like background music and background images) - you can load as you do this like with web )

2) add that all external files to project iOS setup. There you will see 'include file'. Without this they will not be compiled to ipa

3) enjoy )

You will fast load 10mb runtime and 10kb main swf and mp3 will stream. If you need play it without any dellays you can preload it to your soundchannel. For example in your app make static class for soundmaganer and load all mp3s there )

Than only plays they when you need. And if you not need it anymore - unload. This will free iOS memory