[30 Aug 2009] memory leak

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
GMKai
Posts: 158
Joined: Mon Feb 15, 2010 10:58 am

[30 Aug 2009] memory leak

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 30 Aug 2009 12:29:59 +0200

Hello,

when using the following code the available memory gets reduced heavily and the free memory only knows one direction...

Is there a way to reduce the memoryconsumption?

Code: Select all

Function p_DefMaxPage(total)
    maxpage=Int(total/(AreaDim-1))
EndFunction

Function p_pagehandling()
    If page >= maxpage
       page=maxpage
       DisableButton(10)
       EnableButton(11)
       Undo(#TEXTOBJECT,10)
    Else
       EnableButton(10)
    EndIf
    If page = 0
       DisableButton(11)
       Undo(#TEXTOBJECT,11)
    EndIf()
EndFunction

Function p_DisplayNationTab()
    CopyBrush(tabbrush,99)
    p_DefMaxPage(NationCount)
    p_pagehandling()
    SelectBrush(99)
       SetFontColor(#BLACK)
       Local fontsize = GetAttribute(#DISPLAY,0,#ATTRFONTSIZE)
       Local y = 0
       Locate(0,y)
       Print("ID")
       Locate(50,y)
       Print("Nation")
       For i = (page*(AreaDim-1)-page) To ((page+1)*(AreaDim-1))
           If (i < NationCount)
               y = y + fontsize
               Locate(0,y)
               Print(t_nation[i][0])
               Locate(50,y)
               Print(t_nation[i][1])
           EndIf()
       Next
    EndSelect()
    DisplayBrush(99,#CENTER,120)
    FreeBrush(99)
EndFunction 
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[31 Aug 2009] Re: memory leak

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 31 Aug 2009 12:53:38 +0200
Hello,

when using the following code the available memory gets reduced heavily and the free memory only knows one direction...

Is there a way to reduce the memoryconsumption?
Well, keep in mind that if layers are enabled, every call to Print() will insert a new layer. And every layer needs some memory. So you should implement some kind of layer managing mechanism: i.e. make sure that you kill all layers that you no longer need (using RemoveLayer()).

Hollywood can't do this automatically because it doesn't know when a layer is obsolete. You have to keep track of all your layers on your own.
GMKai
Posts: 158
Joined: Mon Feb 15, 2010 10:58 am

[03 Sep 2009] Re: memory leak

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 03 Sep 2009 09:42:02 +0200

Is it true even if I use "SelectBrush" when Printing? I ask because I use

Code: Select all

info = GetAttribute(#DISPLAY,0,#ATTRLAYERS) 
to get the count of added layers and this returns only one added layer.

Nevertheless removing Layers based on this number helped.
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[03 Sep 2009] Re: memory leak

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 03 Sep 2009 22:09:07 +0200
Is it true even if I use "SelectBrush" when Printing? I ask because I use

info = GetAttribute(#DISPLAY,0,#ATTRLAYERS)

to get the count of added layers and this returns only one added layer.
Yeah, this is a bug. Fixed in v4.5. In v4.0 #ATTRLAYERS will only be correct if no SelectXXX() is active.
Nevertheless removing Layers based on this number helped.
Good!
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[03 Sep 2009] Re: memory leak

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 03 Sep 2009 22:25:01 +0200

By the way, tracking memory usage will be much easier with Hollywood 4.5 because it has a OpenResourceMonitor() function which opens a resource monitor that shows the number of brushes, anims, layers, bgpics, sounds, etc etc. currently in memory and constantly updates these values. This is very useful for debugging the memory efficiency of your scripts. If your layers constantly get more and more, then your code is bad :-)
Locked