Highlighted

Memory management (android)

Explorer ,
Feb 26, 2015

Copy link to clipboard

Copied

Hio!

I'm developing a 2D board-game that's using between 120-190mb of ram.

I'm not using object pooling but I'm nulling movieclips when they're not added to stage.

When minimizing the app I stop all timers and remove everything from stage, still it takes up 120mb ram when checking processes.

Do you have any tips or tricks for lowering RAM-usage?

Is there some kind of variables hogging more resources than others?

Thanks!

/T

TOPICS
Development

Views

294

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Memory management (android)

Explorer ,
Feb 26, 2015

Copy link to clipboard

Copied

Hio!

I'm developing a 2D board-game that's using between 120-190mb of ram.

I'm not using object pooling but I'm nulling movieclips when they're not added to stage.

When minimizing the app I stop all timers and remove everything from stage, still it takes up 120mb ram when checking processes.

Do you have any tips or tricks for lowering RAM-usage?

Is there some kind of variables hogging more resources than others?

Thanks!

/T

TOPICS
Development

Views

295

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 26, 2015 0
Engaged ,
Feb 27, 2015

Copy link to clipboard

Copied

Im not certain how memory works between the AIR runtime and Android, but you probably don't need to worry about it too much(And by not worry, I don't mean failing to null out objects, timers, listeners, etc that you aren't using anymore. You should still do that.). Android is supposed to be great about memory management. If your app isn't the currently active app that a user is running and that active app needs more memory than what is available, Android will start clearing up things using RAM to free it up for apps and services that actually need it.

RAM: What it is, how it's used, and why you shouldn't care | Android Central

As far as optimization tips, that may require more details about your app, such as assets and coding methods. Object pooling would be better if you are frequently adding and removing objects from the stage. You can search online for AS3 optimization techniques and find lots of broad information, like using int and uint over Number if you don't need decimals for numbers, using Vector arrays over Array, use int() over Math.floor(), etc. Some things that I have personally found to be faster(sometimes a lot faster, sometimes insignificantly faster) is using while loops over For loops and using "i+=1" over "i++". Im sure others here can provide better tips than I when it comes to assets as pretty much all of stuff I do is created with code and I use as little Library assets as possible.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 27, 2015 0
Explorer ,
Feb 27, 2015

Copy link to clipboard

Copied

Thanks for your fast response!

The problem with my app is bitmaps, after clearing the library memory usage went from 160 to 65.

Most of the menus/scenes consists of pngs (some jpegs) as large as 400x400 (larger background-panels are tiled).

The stage is set to 1920x1080.

Read about that bitmapdata is the way to go when freeing memory instantly, don't know if it will help in my case.

The main issue behind my topic is a native extension communicating with facebook, it seems 15% of the times when waiting for response after posting on wall it doesn't respond.

This problem goes away when removing the bitmaps from library thus giving more memory, I've emailed the creator of the extension regarding this today and we'll see what he says.

*Samsung Galaxy s3 @ air 16

Cheers!

/T

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 27, 2015 0
Explorer ,
Mar 04, 2015

Copy link to clipboard

Copied

My solution was to use bitmap-data in movieclips containing large images, to instantly free memory on removal/nulling. I added eventlisteners for ADDED & REMOVED to handle reading/clearing bitmaps.

I also accidentaly stored an array of references to objects containting bitmaps which added 30mb of ram usage.

/T

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 04, 2015 0
swamp222 LATEST
Explorer ,
Mar 07, 2015

Copy link to clipboard

Copied

The strange thing is that when I remove all bitmaps from library the memory use is at 25-30mb, when all bitmaps are in library but none of them are on stage or in any created variable the memory use goes up to 65-70mb. When I add any image to stage during this period memory use goes to 85.

Any thoughts about this?

Are jpegs more memory friendly than pngs?

Tried removing export in frame 1.

Thanks!

/T

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 07, 2015 0