[Gambas-user] Allocations non freed.

Kevin Fishburne kevinfishburne at ...1887...
Thu Oct 31 19:25:29 CET 2013


On 10/31/2013 03:08 AM, Fabien Bodard wrote:
> 2013/10/29 Tobias Boege <taboege at ...626...>
>
>> On Mon, 28 Oct 2013, Kevin Fishburne wrote:
>>> On 10/28/2013 03:50 PM, Tobias Boege wrote:
>>>> On Mon, 28 Oct 2013, Jorge Carri?n wrote:
>>>>> I have a component who inherits from gridview.
>>>>> It's not a complicated thing, but when its included in a project
>> allways
>>>>> produced a warning in the console about allocations non freed like
>> this.
>>>>> gbx3: warning: 82 allocation(s) non freed.
>>>>>
>>>>> I have read that it references to variables who remains allocated in
>> ram
>>>>> after the end of the program but I don't any clue about how prevent
>> this.
>>>>> I've coded something like this in al close event of all parts of the
>>>>> component
>>>>>
>>>>> variableObjecA=null
>>>>> variableNumericB=0
>>>>> variableStringC=""
>>>>>
>>>>> But the warning still remains.
>>>>>
>>>>> Someone knows a way to prevent or debug this?
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>> I don't really know a good way to debug it. A solution might be to
>> send your
>>>> project to this list so we could have a look.
>>>>
>>>> BTW, 82 is an impressive number! I never came above 10. :-)
>>>>
>>>> Regards,
>>>> Tobi
>>> Mine have gotten in the 800's, possibly higher, so I'd like to know
>>> what's up with that as well. In my case I think it may have something to
>>> do with arrays of structures where one of the structure properties is an
>>> array of OpenGL textures. Here are some snippets:
>>>
>> Doesn't sound harmful what you describe. However, if you have any circular
>> references in this hierarchy (strictly speaking, if you have, it is not a
>> hierarchie anymore but let's be sloppy on this), Gambas will get problems
>> automatically freeing your objects. But IIRC, in this case, Gambas will
>> detect that you have produced circular references and tell you so.
>>
>> Also, it can be that whatever component deals with OpenGL textures (maybe
>> gb.opengl?) is buggy. Maybe it doesn't release all memory it allocated...?
>>
>>> Public Struct Render_Texture
>>>     Loaded As Boolean
>>>     FileName As String
>>>     ID As Integer[]
>>>     SubID As Short
>>>     Width As Short
>>>     Height As Short
>>>     Frames As Short
>>>     LastUsed As Single
>>> End Struct
>>>
>>> Public tiPWO[32768] As Struct Render_Texture
>>>
>>> Public Sub Textures_PWO_Load()
>>>
>>>     ' Load all PWO images into OpenGL textures.
>>>
>>>     ' General declarations.
>>>     Dim Counter1 As Short ' General Counter.
>>>     Dim Counter2 As Short ' General Counter.
>>>
>>>     ' Load PWO textures.
>>>     For Counter1 = 0 To 32766
>>>       ' If PWO image files exist then load them into OpenGL textures.
>>>       If Exist(BasePath & "/image/pwo/" & Counter1 & "_0.png") Then
>>>         tiPWO[Counter1].ID = Gl.GenTextures(16)
>>>         For Counter2 = 0 To 15
>>>           tTemp = Image.Load(BasePath & "/image/pwo/" & Counter1 & "_" &
>>> Counter2 & ".png")
>>>           tiPWO[Counter1].Loaded = True
>>>           tiPWO[Counter1].Height = tTemp.Height
>>>           tiPWO[Counter1].Width = tTemp.Width
>>>           Gl.BindTexture(Gl.TEXTURE_2D, tiPWO[Counter1].ID[Counter2])
>>>           Gl.TexImage2D(tTemp)
>>>           Glu.Build2DMipmaps(tTemp)
>>>           Settings_MipMap(True)
>>>           Settings_Wrap(False)
>>>         Next
>>>       Endif
>>>     Next
>>>
>>>     ' Clear temporary image.
>>>     tTemp.Clear
>>>
>>> End
>>>
>> Doesn't look wrong in my eyes. But the OpenGL stuff is a black box to me.
>>
>> Regards,
>> Tobi
>>
>> --
>> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>>
>>
>> ------------------------------------------------------------------------------
>> Android is increasing in popularity, but the open development platform that
>> developers love is also attractive to malware creators. Download this white
>> paper to learn more about secure code signing practices that can help keep
>> Android apps secure.
>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> tTemp=null to free the object But i'm not sure that solve all. You have
> tester your class as it ?

tTemp is a publicly declared variable of datatype Image in the Render 
module which is used to temporarily hold a texture loaded from disk 
before it's fed to OpenGL to become an OpenGL texture, so it shouldn't 
be creating "instances" or anything like that. Good to know just to 
assign Null to an image to nuke it, though.

Maybe I need to explicitly clear/destroy my OpenGL textures.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list