Leaking memory
BlitzMax Forums/Brucey's Modules/Leaking memory
| ||
19,5Mb .exe start 20,8Mb run script first time 21,9Mb run script second time 23,0Mb run script third time 24,1Mb run script 4 time 25,1Mb run script 5 time 26,2Mb run script 6 time 27,3Mb run script 7 time 28,5Mb run script 8 time 29,6Mb run script 9 time 19,5Mb run script 10 time (this was strange never seen) 20,6Mb run script 11 time 21,9Mb run script 12 time 22,9Mb run script 13 time 24,0Mb run script 14 time 25,0Mb run script 15 time 26,1Mb run script 16 time 27,4Mb run script 17 time 28,3Mb run script 18 time 29,4Mb run script 19 time 30,7Mb run script 20 time 31,7Mb run script 21 time 32,7Mb run script 22 time 33,8Mb run script 23 time 34,0Mb run script 24 time 36,1Mb run script 25 time When script stop I try clean up all the scrip objects like this: If BLLua.MOBii_Panel.Length Then For Local i:Int = 0 To BLLua.MOBii_Panel.Length-1 ' BLLua.MOBii_Panel[i].DestroyChildren() If BLLua.MOBii_Panel[i] Then if BLLua.MOBii_Panel[i].Img Then BLLua.MOBii_Panel[i].Img.Free() If BLLua.MOBii_Panel[i].Panel Then BLLua.MOBii_Panel[i].Panel.Free() BLLua.MOBii_Panel[i].Img = Null BLLua.MOBii_Panel[i].Panel = Null BLLua.MOBii_Panel[i].Free() BLLua.MOBii_Panel[i] = Null End If Next End If BLLua.MOBii_Panel = Null If BLLua.MOBii_TAB.Length Then For Local i:Int = 0 To BLLua.MOBii_TAB.Length-1 ' BLLua.MOBii_TAB[i].DestroyChildren() If BLLua.MOBii_TAB[i] Then BLLua.MOBii_TAB[i].Free() BLLua.MOBii_TAB[i] = Null End If Next End If BLLua.MOBii_TAB = Null.DestroyChildren() only work if there is any children, but is no children program crash so I don't use So I make a function to clean up the children in a panel: ' -----------------------------------------------------------------------[BLLua.Killpanel]--- Method Killpanel(b:Int) Local q:Int = 0, ok:Int = 0 For Local i:TPanel = EachIn MOBii_Panel If i.getID() = b Then ok = 1; Exit q :+ 1 Next If ok Then If MOBii_Panel[q] Then Local ii:wxWindow[] = MOBii_Panel[q].Panel.getChildren() If ii Then For Local i:wxWindow = EachIn ii If i.getID() Then i.hide(); i.Free() ' I don't know if i is a pointer to the child or only a local copy of MOBii_Panel[q].Panel's child? (the object get hidden, but I am not sure if I free the real object or the copy?) info OKK + "delete object " + i.getID() + " :: panel(~qclear~q, " + b + ")" Next ' MOBii_Panel[q].Panel.DestroyChildren() End If MOBii_Panel[q].Free() ' MOBii_Panel[q] = Null ' my list is static so I can't erase the object, not really good! info OKK + "panel(~qclear~q, " + b + ")" End If End If End MethodI see fron the taskmgr that for every time I stop/restart the script it shockingly eat in average 1,1M bytes of memory. My main question is can I monitoring object: MOBii_Panel (Examples on objects: wxListBox, wxFlatNotebook, wxScrolledWindow) to see how many bytes that is allocated? so I can see when it restarts what happen to to the objects, because I am clueless where the memory go! If I keep restarting the script by pressing a key the application just pop gone after around 120Mb |