Here is another example of the apparent 'memory leaking' based on code posted in the radomizing a list topic.
My results:
*****************************************************************
Memory allocated after object creation: 289870
Memory allocated after randomizing: 1110206
*****************************************************************
is the memory leaking? Why is MemAlloced() increasing? Since the objects and lists are created... why is shuffling the lists around causing the memory to grow significantly?
My results:
*****************************************************************
Memory allocated after object creation: 289870
Memory allocated after randomizing: 1110206
*****************************************************************
is the memory leaking? Why is MemAlloced() increasing? Since the objects and lists are created... why is shuffling the lists around causing the memory to grow significantly?
' randomize a list of items in a list Global list:TList=CreateList() Global memory1:Int Global memory2:Int Type foodtype Field name$ Field price# Method Add(n$,p#) Local f:foodtype=New foodtype f.name$=n$ ; f.price=p ListAddLast list,f EndMethod Method ShowList() Print "----------------------" For Local f:foodtype=EachIn list Print f.name$+" - "+f.price Next EndMethod Method RandList(numtimes=3) For Local n=1 To numtimes For Local f:foodtype=EachIn list If Rnd()>0.3 ListRemove list,f ListAddLast list,f FlushMem EndIf Next Next EndMethod End Type SeedRnd MilliSecs() For Local i = 0 To 1000 Local f:foodtype f=New foodtype f.Add "pizza",2.50 f.Add "sausage",0.75 f.Add "pie",1.53 f.Add "onion",0.21 f.Add "soup",0.97 f.Add "crisps",0.29 Next memory1 = MemAlloced() f.ShowList Print "~nrandom ..." f.RandList(1) memory2 = MemAlloced() f.ShowList Print "*****************************************************************" Print "Memory allocated after object creation: "+memory1 Print "Memory allocated after randomizing: "+memory2 Print "*****************************************************************" DebugStop End