TList memory management

BlitzMax Forums/BlitzMax Beginners Area/TList memory management

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

why in this code there is a memory leak?

please help-me!
my head explode! ;)

Strict

Type tStruct
	Field n		: Int
	Field Nome	: String
EndType

Type cTest
	Field Lista: TList
	Function Create: cTest(Elements: Int)
		Local t			: cTest = New cTest
		Local NewElement: tStruct
		
		t.Lista = New TList
		
		For Local j: Int = 0 To Elements
			NewElement = New tStruct	
			NewElement.n = j
			NewElement.Nome = "UserName "+j
			ListAddLast(t.Lista, NewElement)
		Next
		Return t
	EndFunction
	
	Method Free()
		ClearList(Lista)
		Lista = Null
	EndMethod
EndType

Global StartMem	: Int = 0
Global ListMem	: Int = 0
Global FreeList	: Int = 0
Global TestList	: cTest

FlushMem()
StartMem = MemAlloced()
Print "************************************************************************************************" 
Print "Start Memory: "+StartMem

TestList = cTest.Create(10000)
FlushMem()
ListMem = MemAlloced()
Print "************************************************************************************************" 
Print "Memory after List Alloced: "+ListMem+" Bytes (Memory Alloced) "+(ListMem-StartMem)+" Bytes"

TestList.Free()
TestList = Null
FlushMem()
FreeList = MemAlloced()
Print "************************************************************************************************" 
Print "Memory After Freeing List and cTest Type: "+FreeList+" Bytes (Differece) "+(FreeList-StartMem)+" Bytes not Released!"

Print "************************************************************************************************" 
End