Memory Leak v66

Monkey Forums/Monkey Bug Reports/Memory Leak v66

Fly-Games(Posted 2012) [#1]
update monkey to 1.66 and game crash in 5 min of use. Low memory in log etc ... I try fo find problem, and find that game can't load picture. Use this simple example. All ok in 1.53 and crash in 1.66.

Is this a Bug?

Example:

Strict

Import monkey
Import mojo

Const SAMPLE : String = "sample.jpg"

Class MyApp Extends App
Private
Field list : List<Image>
Field count : Int
Field image : Image

Public
Method OnCreate : Int()
'list = New List<Image>
'list.AddLast LoadImage(SAMPLE)
image = LoadImage(SAMPLE)
count = 1

SetUpdateRate 60

Return Super.OnCreate()
End

Method OnUpdate : Int ()
If MouseHit()
'image.Discard 'add this line and all Ok in 66
image = LoadImage(SAMPLE)
count = count + 1
End

Return Super.OnUpdate()
End

Method OnRender : Int ()
Cls

'DrawImage list.Last(), 0, 0
DrawImage image, 0, 0
DrawText count, 0, 0

Return Super.OnRender()
End
End

Function Main : Int ()
New MyApp
Return 0
End


MikeHart(Posted 2012) [#2]
To many ENDs for my taste. Why do you always call Super.xxxx ?

And please use the specific forum codes to display code. It is hard to read.

http://www.monkeycoder.co.nz/Community/forum_codes.php


Fly-Games(Posted 2012) [#3]
remove "super" from return.




LOG:
..... TAP THE SCREEN HERE ...
65
66
2012-11-06 16:48:24.086 MonkeyGame[6516:907] Received memory warning.
67
.... TAP AGAIN
76
2012-11-06 16:48:54.692 MonkeyGame[6516:907] Received memory warning.
77
... AND MORE TAP ....
85

... AND HERE CRASH

If i use image.Discard - all work good

if i use Monkey 53 - all work good without image.Discard


Difference(Posted 2012) [#4]
I just had the same issue and made my framework force image.Discard. That solved it.

I'm pretty sure there is a image.discard issue, because I have used the same code a lot and had no problem until now.

I profiled in my own project in xcode, and can confim Fly-games findings.


Fly-Games(Posted 2012) [#5]
I use Monkey v64. All work ok in old version, i add iOS 6 screen rotation fix. I would like to fix it in future Monkey builds. Thank for all :)