Understanding Blitz Memory Thread

BlitzMax Forums/BlitzMax Programming/Understanding Blitz Memory Thread

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.

Code to see the reference count.

Strict

Type TestObject
  Field Blah : Int=66
End Type


Function Count(o:object)
 local p:int ptr = int Ptr(byte ptr o)-1
 const BBZERO:Int=-2147483648
 Print p[0]-BBZERO
end function

Function Showlocal()
  Print "Local Reference Counting"
  local l:TestObject= New TestObject
  Count(l)
  local l2:TestObject=l
  Count(l)
end function

Function ShowGlobal()
 Print "Global Reference Counting" 
 Global g:TestObject= New TestObject
 Count(g)
 Global g2:TestObject =g
 Count(g)
end Function

ShowLocal()
Showglobal()


Here is code to show you but this example demonstrates what I was describing with Locals vs Globals it doesnt work the same way. Locals are on stack not reference counted Globals are.

There is really no useful way to track memory usage with reference count checking.

Unfortunatly with GC you really have to trust its working right. Biggest mistake with BMAX you can make is cyclical references or using handles.

Doug Stastny