Freeing Memory?

BlitzMax Forums/BlitzMax Programming/Freeing Memory?


m_pTGamePlayScreen is a field of the TReferee object. TReferee exists throughout the life of the game. it is not going to fall out of scope?


OK, so the TReferee object's m-pTGamePlayScreen field (which you have set to null) will no longer reference the
TGamePlayScreen object. If the TGamePlayScreen object is not on a list and nothing else references it, the memory it used will be freed next (or returned to the 'pot') next time GC is run.
As far as I know there is nothing that can list existing objects.
Global alllist=CreateList()
Type treferee
  Field t2:ttest
End Type
Type ttest
  Field t1:ttest1
End Type
Type ttest1
End Type
Graphics 640,480
For x = 0 To 5000
  Cls
  mynew:treferee = New treferee
  mynew.t2:ttest = New ttest
  mynew.t2.t1:ttest1=New ttest1  
  ListAddLast alllist,mynew.t2.t1
  DrawText  GCMemAlloced(),0,0
'  ListRemove alllist,mynew.t1
  mynew.t2 = Null
  DrawText  GCMemAlloced(),0,20
  DrawText x,0,40
  Flip
Next


I might be missing something here but you keep adding to the question. It might be best to post the smallest example which shows the problem.