windows phone 8.1 gfx memory
Monkey Targets Forums/Windows 8/windows phone 8.1 gfx memory
| ||
Hi After my initial app crashing 'for no reason' when loading images. I decided to write a test app. Strict #test=1 Import mojo Function Main:Int() New Test() Return 0 End Function Class Test Extends App Const FPS:=30 Field timer:DeltaTimer Const game_width:=600 Field scale:Float Field game_height:Float Field counter:Int=0 Field img_counter:Int=0 Field img:Image[101] Method OnCreate:Int() Local i:Int SetUpdateRate(FPS) #If test=1 i=0 While i<60 Print i img[i]=LoadImage("circle.png") i=i+1 Wend #End scale=DeviceWidth()/Float(game_width) game_height=DeviceHeight()*scale counter = 0 Print "init end" Return True End Method Method OnUpdate:Int() Local t:Int Print "update start" Print "update end" Return True End Method Method OnRender:Int() Local i:Int Print "render start" PushMatrix() Cls() Scale scale,scale #If test=2 counter = counter + 1 If counter Mod 5=0 If img_counter<100 Print img_counter img[img_counter] = LoadImage("circle.png") img_counter=img_counter+1 End End #End i=0 While i<100 If img[i]<>Null Print "drawing image "+i DrawImage img[i],i*5,i*5 End i=i+1 Wend PopMatrix() Print "render end" Return True End Method End Class There are 2 tests... Test 1 --------- Loads images during OnCreate only. At about 80 images, my phone decides to crash inbetween Oncreate() and OnUpdate(). You can tell as the output says "end init" but doesnt display any "start" message. Test 2 --------- This loads images during OnRender(). The more it loads eventually the app will crash with a GC error. Can people please test on their 8.0 and 8.1 devices please and display the results? I don't seem to get these memory issues on Android,XNA or HTML, and just wondering if a) its my set up b) it Windows 8.1 and Monkey c) its just crap coding by me ;-) ta! EDIT ------ removed my pantson lib being imported. it wasnt required in the above example Also the circle.png is a 200*200 simple image with a circle in. Please create this image or something like lit. Larger images make it crash quicker, that leads me towards gfx memory |
| ||
Should you be loading an image in OnRender ? |
| ||
I've had no issues on other OS's and it allows loader bars and in game level loading. |
| ||
I'd say check your code. Load images on OnUpdate (not OnCreate, or OnRender), and check what you're doing: I'm not using Win 8.1, but on 8.0 it works without problems (at least on version 77b, I didn't upgrade it yet) |
| ||
Thanks SLotman Does Windows 8.0 every run out of mem or randomly crash on 8.0 on TEST 1? which hardware are you using? |
| ||
Slotman -- I am very new but shouldn't loading images be handled in the OnCreate method and not the OnUpdate or OnRender Seems like if you did it there you would constantly be doing loadImage at what ever the SetUpdate rate was set to ? Just trying to make sure I have a correct understanding how mojo works. Thanks Rod |
| ||
slightly off topic but... images can be loaded during onRender() and onUpdate() and yes they would load every loop. in my usual code library (not the example above), my onRender and onUpdate has a game_state case inside that will perform different things depending on wether game_state is game_play, game_title, game_loading. This way i can have a loader bar at the start in game_loading, once finished set game_state to game_title, when press play set game_state to game_play |