Memory gap between html5 and windows

Hi everyone!

I have a simple project in which I load a 8192*8192 png.

On html5 my project uses around 10 mb before the loading.
On windows it uses 0.27 mb before the loading.
I am using System.totalMemory to profile the RAM.

Once I load the bitmap i get roughly 12 MB on html5. But on windows it’s 256 MB. Which seems normal since the memory the bitmap should require once decompressed is 8192 * 8192 * 4 MB.

Now what I don’t get is why the memory used on html5 is so low. Am I doing something wrong on the windows target? How can I reduce the memory on windows (beyond scaling down my png)?

Thanks for your time!

What happens if you try using bitmapData.disposeImage ()?

That may dump the software version of your texture, so that it only uses graphics memory

1 Like

No changes. Here is my code :

Assets.loadBitmapData("assets/bob.png", false).onComplete(function (e) {
	var bitmap:Bitmap = new Bitmap(e);
	bitmap.scaleX = bitmap.scaleY = 0.05;

I even force the garbage collection to be sure. The method dispose does free the memory but the bitmap is no longer visible (wich seems reasonnable since it has left the VRAM).

disposeImage is supposed to hold onto the memory until after the object is rendered the first time. You might have to wait a frame or two before running GC for it to clear out.


Works like a charm thanks !

1 Like