Phone 8.0 - Out of memory on load/discard image

Monkey Targets Forums/Windows 8/Phone 8.0 - Out of memory on load/discard image

BinaryItch(Posted 2015) [#1]
I've been having problems with my game explicitly on Windows Phone 8, suspecting that I am running out of memory due to graphics resources not being cleaned up after images are discarded. I decided to put together a small app to test:



This runs indefinitely on glfw, desktop targets with no impact on memory. When I run it on a WP8 emulator (WVGA 512MB) I get to around 570 images allocated and discarded, then it crashes. I'm getting the following output in Visual Studio:


The thread 0xa38 has exited with code 0 (0x0).
First-chance exception at 0x7705277C in MonkeyGame.exe: Microsoft C++ exception: _com_error at memory location 0x013AE574.
First-chance exception at 0x7705277C in MonkeyGame.exe: Microsoft C++ exception: _com_error at memory location 0x013AE9B0.
... Omitted ~50 additional entries the same as above
First-chance exception at 0x7705277C in MonkeyGame.exe: Microsoft C++ exception: _com_error at memory location 0x013AEAEC.
D3D11: Removing Device.


It seems discarded images are retaining their allocated memory... Are we aware of a fix for this?

Ste, Binary Itch


Amon(Posted 2015) [#2]
From the Monkey Docs:

Finalizers are not supported. If you need an object to be 'destroyable', you will need to add a 'Destroy' type method.



BinaryItch(Posted 2015) [#3]
From the documentation for Image::Discard

"Discard any underlying resources associated with the image.

This isn't normally necessary because automatic memory management will eventually take care of this for you. However, on devices with limited resources this may which to do this manually."


Pharmhaus(Posted 2015) [#4]
Sound like a bug to me.
Try to repost @ the bug forums.


BinaryItch(Posted 2015) [#5]
Ah, I didn't spot the bug forums :) will do, thanks!


Amon(Posted 2015) [#6]
I tested the example on my Nokia lumia 635. It bombed out at 125.

This is the output, won't post it all because there is a lot but it definitely has something to do with the gc.

		GC_REMOVE_NODE( p );
6A73EE78  ldr         r3,[sp,#p]  
6A73EE7A  adds        r1,r3,#4  
6A73EE7C  ldr         r3,[sp,#p]  
6A73EE7E  adds        r3,r3,#8  
6A73EE80  ldr         r3,[r3]  
6A73EE82  adds        r2,r3,#4  
6A73EE84  ldr         r3,[r1]  
6A73EE86  str         r3,[r2]   <<<<<<<<<<<<<<<<<<Points Here
6A73EE88  ldr         r3,[sp,#p]  
6A73EE8A  add         r1,r3,#8  
6A73EE8E  ldr         r3,[sp,#p]  
6A73EE90  adds        r3,r3,#4  
6A73EE92  ldr         r3,[r3]  
6A73EE94  add         r2,r3,#8  
6A73EE98  ldr         r3,[r1]  
6A73EE9A  str         r3,[r2]



BinaryItch(Posted 2015) [#7]
It appears the project I was working on was referencing a significantly older version of Monkey to the version I'm running locally. I've run the test on the latest version and it's working fine. Just hit 20,000 allocations and discards. Thanks for the help.