FreeBrush()

BlitzMax Forums/MiniB3D Module/FreeBrush()

LT(Posted 2007) [#1]
I've noticed that this is an empty method. I've been working on loading and unloading of data and the brush I create adds 260 bytes that never gets released. Since the FreeBrush() command doesn't do anything, can someone tell me how to achieve this?


LT(Posted 2007) [#2]
Okay, it's not 260 bytes. The brush itself only seems to hold on to 30 bytes that don't get released using GCCollect and the rest is something related to the texture. Is it possible to recapture the memory that is used by these things?


Leon Drake(Posted 2007) [#3]
is the brush still current on any mesh surfaces?


LT(Posted 2007) [#4]
No, I commented out the mesh building so all I'm doing is creating a brush. The brush with a texture uses 260 bytes that never gets unloaded. If I comment out the texture part, the brush by itself uses 30 bytes that never get unloaded.

NOTE: Those 30 bytes don't add up over and over. If I load and unload the same data multiple times, it doesn't add 30 every time (so it's not a memory leak, per se). It's just the FIRST time. This makes me wonder if there's some memory buffer that gets created for every brush that cannot be reclaimed until the whole thing is shut down.


LT(Posted 2007) [#5]
Okay, here's an example, but it's only 12 bytes in this case that don't get reclaimed. Does anyone know what is actually going on here or have advice for a better way to do this?

F1 Loads and F2 Unloads.

Framework BRL.System
Import klepto.minib3d

Graphics3D 1024, 768, 32, 1

Type test
	Field b:TBrush

	Function Create:test()

		t:test = New test
		t.b = CreateBrush(255,255,255)

		Return t

	End Function

	Method Free()

		b = Null

	End Method

End Type

Global tst:test

While Not KeyHit(KEY_ESCAPE)		

	If KeyHit(KEY_F1) = True
		If tst = Null Then tst = test.Create()
	End If

	If KeyHit(KEY_F2) = True
		tst.Free()
		tst = Null
	End If

	UpdateWorld()
	RenderWorld()

	GCCollect()
	mem = GCMemAlloced()
	Text 0, 50, mem

	Flip ( True )

Wend



Leon Drake(Posted 2007) [#6]
hmm somewhere in the module the brush must still be referenced. looking it over right now.


LT(Posted 2007) [#7]
It doesn't appear to be the brush, but rather the type that holds it.