Why Windows Phone 8 app consumes so much memory in Cocos2dx-2.2.6?

Hi. We’re trying to port our game to WP8 using Cocos2dx-2.2.6. But there’s a little problem with textures: we using 16 bit png textures, RGBA4444 is set as default texture format:

CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);

But in the very beginning of the game, memory indicator in the top of the screen says that app uses over 150 MB of device memory!!! (on iOS we have ~50 MB on the same screen). CCTextureCache dump says:

CCTextureCache dumpDebugInfo: 12 textures, for 41199 KB (40.23 MB) - 16 bits

I thought that it is very strange, that textures uses less then half of app’s memory, and so I decided to set default texture format to RGBA8888 and check dump once again:

CCTextureCache dumpDebugInfo: 12 textures, for 80495 KB (78.61 MB) - 32 bits

But the total memory has remained THE SAME: > 150 MB !!!

Is anybody knows why changing the texture format doesn’t affects total memory size and why the WP8 app consumes so much memory?

Thanks for help!

I believe it’s related to the ANGLE project that is used to support WP8. Microsoft reduced the texture load by half with the latest version, but as far as I understand it’s only used in 3.x. It wouldn’t surprised me if maybe the DirectX texture format that was used in the older version of ANGLE was always 32-bit?

Either way I believe you’ll have to live with that issue if you want to run on WP8 devices. If you aren’t already loading/unloading textures based on which scene or level you’re on you may have to start managing them.

Test first of course. If it runs fine on 512 devices then you don’t really have to worry too much.

Why would 150MB even be a problem? Modern devices come with at least 1GB of RAM, 2GB being the norm and some even having 3GB or 4GB. I don’t think that your memory consumption would lead to any problems.

I also agree with @stevetranby. It surely is caused by all those wrappers/layers instead supporting/using the native backend directly.

@iQD Actually most WP8 phones have 512MB ram and something like an semi-documented ~175MB ram usage limit before app is quit by the OS. This is why we’ve decided to only support WP8.1+ because the difference from old ANGLE and new ANGLE framework in our game is 40% reduced resource usage just by re-building and no other changes.

@Max - you could look into the DirectX renderer that has been worked on by a few in the community. It should ideally eliminate any real difference between iOS/Android and WP8 resource usage.

Yeah, sorry, my bad. I just read up on this, and you are totally correct.
At the time of posting, I was some how referring to Android phones.

But aren’t those 512MB devices pretty old/low resolution models?
Referring to that list, it seems they are just in the minority:

Well, there are plenty of 512MB low resolution models.

Speaking of WP8 in general. Does it even make sense to release on WP8? How big is the piece of the cake, you are leaving behind?

We’ll know more hopefully by end of month. It’s quite possible that WinPhone in general is too small a piece to bother with, and it’s quite possible that any meaningful market share will increasingly become 1024MB+ devices. But the next 12 months the stats will very likely skew toward 512MB and “low resolution” (which we support already as target -> 480x320, with limited higher res backgrounds for > 800x480 devices).

However we’re testing it out in case the smaller device count still ends up delivering a much larger % of user base purchases due to limited “quality” games/apps on the platform. It’s a very small risk though - not a lot of time put into testing above the normal VS2013 and Win32 testing.

Anyway, In the end you may be right. We’re still going to test out the WinPhone (WinUniversal Store) market.

Thanks for your answers, guys. I’ve made some tests and realised that changing pixel format in cocos-3.4 has no effect on memory just like in cocos-2.2.6. But using of DXT-compressed textures instead of PNGs helps to lower memory usage by 40-60%. So, we deceided to use DXT textures and, most likely, migrate to 3.4 version.
To use DXT textures you must make some changes in cocos sources, take a look: http://www.slideshare.net/phongcao9/memory-optimization-in-cocos2dx-wp8-using-compressed-textures

Smart idea with DXT, never thought of improving by translating image formats (and would rather not have to). I’m curious now if this would improve things even further than 3.4 already has. Thanks!

But don’t forget, that DXT compression is a lossy compression, which is where the lower memory usage comes from.
Depending on your graphics(e.g. style and features), it can introduce ugly block artifacts, gradient and aliasing issues.

1 Like