memoryleak=FreeGadget()
BlitzMax Forums/BlitzMax Programming/memoryleak=FreeGadget()
| ||
I'm finding that I am getting a memory leak with the FreeGadget command. Even a simple test program such as this will see the ram usage spiral at a steady and uncomfortable rate.Global hello:TGadget Global window:TGadget window=CreateWindow("World",0,0,200,200) Repeat createanddelete() Until KeyDown(KEY_ESCAPE) Function createanddelete() hello=CreateButton("hello",0,0,100,100,window) FreeGadget hello End Function Am I doing something wrong? When I delete a gadget I wish to utterly destroy it, I think BlitzMax is keeping it in memory incase it is re-used but when I reuse the same gadget a new instance is made anyway, or something. I've tried doing GCCollect manually, but it doesnt make a difference. I'm compiling using Intel Mac OS X version of Blitz Max. Thank you. |
| ||
out of question, what happens when you use "Hello=null"? |
| ||
oh sorry I missed that off the sample code but it's the same as that is what I am doing in my actual application. |
| ||
Shouldn't need to, hello is constantly being over written anyway. |
| ||
Tell us what happens when you insert a PollSystem() after the CreateButton() and FreeGadget() command, i.e.Global hello:TGadget Global window:TGadget window=CreateWindow("World",0,0,200,200) Repeat createanddelete() Until KeyDown(KEY_ESCAPE) Function createanddelete() hello=CreateButton("hello",0,0,100,100,window) PollSystem() FreeGadget hello PollSystem() End FunctionThe thing to note about Cocoa (OS X's GUI Library) is that many of the GUI commands only execute upon a call to PollSystem() which is usually called by WaitEvent() in a standard event driven BlitzMax app. |
| ||
Even on your code Seb, memory usage keeps rising at a rate of a couple of mb a minute. It strikes me that there appears to be a memory leak in the MaxGUI with the OS X module? EDIT: 17mb to 25mb in the time it took to write the above :) |
| ||
I suggest you post this in the MaxGUI bug reports - although Skid's probably really busy right now with Axe.Win32MaxGUI development, this is quite a severe memory leave. Make sure you specify your CPU architecture (PPC/Intel) and the version number of Brl.CocoaMaxGUI from the Modinfo part of the docs, just in case. I'll check if I get the same results on my G3 later if it decides to boot (its on its last legs ;-) ). Mind you, there are quite a few Cocoa bugs stacking up in that Bug Report forum. |
| ||
Cheers, posted ( http://www.blitzmax.com/Community/posts.php?topic=70301 ) at least from this post I can rest easier knowing it's not me miss-understanding BlitzMax - some things about this compiler still confuse me! :) |
| ||
Hi, I added a call to GCMemAllocated and checked for max ram used at anyone point and it ceilings at around 32 meg, although it is fluctuating between 17 and 32MB but never gets any higher than 32MB This is what I changed If GCMemAlloced() > usedram usedram = GCMemAlloced() End If SetStatusText(window, usedram) This is on PC with latest sync-mods and V1.24 Cheers. |
| ||
I'm running seb's version of the code here and watching the memory usage in the Mac equivellent of Task Manager (Activity Monitor) and so far i'm up to 49mb and it's still steadily rising. I believe this is a memory leak specific to the OS X version of the GUI module, so PC tests aren't really proving/disproving the problem other than proving it's specific to OSX. :) 51mb now... |