I am almost done with a rather large RPG containing over 2000 music and bitmap assets. When I run this app in iOS, Android or on PC, my RAM usage is well above 100MB. I have no timeline code. The game is broken into about 100 AS3 classes (1 per level).
As an experiment, I have deleted all of my code and packaged an "empty" app. My RAM usage is still over 100MB. This leads me to believe that my entire libraray is loaded into RAM when my app launches.
Is there a way to control or prevent this?! Loader class? External SWC of assets?
Let me know if this helps.
Thanks and regards,
Adobe Flash Professional Team
I tried exporting a large number of audio assets as a SWC, removing them from my project library and importing them into the project under Actionscript settings. I have them set to "merge into code".
This is NOT reducing the amount of memory (RAM) my app is using. Should I not merge the SWC into code? is there some method I can use to not immediatly call all of the assets bundled into a SWC when I launch the app?
Whatever you compile into your application is loaded into RAM when application unfolds. There is nothing you can do about it.
SWC will not help. SWC is used, mainly, as an external library at authoring time and all the objects referenced at authoring will be still compiled into application unless you use RSLs and load extra libraries at runtime. By checking "merge into code" you still instruct compiler to include all assets. If you don't merge into code - you will have to write logic that loads libraries at runtime.
The main issues in your case is that you compile media assets into the application. Videos, sounds and, to a lesser extent, images are the biggest memory hogs. You should load them at runtime - not to include them into your application. Especially this concerns sound files - Flash is very good at runtime playback/streaming.
When I say "runtime loading" I don't mean necessarily loading from the network/Internet. Since you are developing mobile apps (I assume using AIR) - you can write these assets into file system at installation and then retrieve them as needed.
It depends on what use cases you need to cover.
You will need to come up with an architecture that will allow for assets loading progression in the conjunction with user experience.
Since, as I understand, this is a mobile app - you are, perhaps, better off saving all files on the device and use them, as needed, at runtime. You would do it with file manipulation capabilities of AIR. I am not talking about compiling assets into the main application but providing them externally - saving them in some folder on a device that you write at installation or first run. This way your main application will be very small and RAM usage will be tamed at any particular moment.
Since this is a game - loading from external source may not be feasible because network/Internet connectivity is not always available.