Get an Object's Ref Count?

BlitzMax Forums/BlitzMax Programming/Get an Object's Ref Count?

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.

There is no BM internal way for what you want, most likely to prevent people messing with it (and because even in a managed system, Engines or SoftwareSystems are notified when something isn't needed anymore ... what you want is a GC ontop of a GC ... sort of not such a good idea as double management will bring up some kind of problem earlier or later but at least for sure)
But there is the unofficial way, thought it is, as always, risky to use and might change at any time:

Type Test
 Field c:Int

End Type

Global t:Test = New test

Print "RefCount: " + Byte Ptr(t)[-4]

Local l:Tlist = New tlist

For Local i:Int = 1 To 10
 l.addlast(t)
Next

Print "RefCount: " + Byte Ptr(t)[-4]