>Let me say a wishlist item I'd much rather have is the ability to backtrack a reference and find the object/memvar that is keeping the reference count from going to zero and thus allowing the object to be removed from memory. Something on the order of a References[] collection.
This has passed unnoticed almost two months ago:
x=create("dummy")
y=x
x.releasereference
?type("x"), type("y")
?isnull(x), isnull(y)
define class dummy as custom
procedure releasereference
Local ai[1]
local i,n, lcExternalVar
n=ainstance(ai, this.class)
for i=1 to n
lcExternalVar=ai[i]
if compobj(eval(lcExternalVar), this)
release (lcExternalVar)
endif
endfor
endproc
enddefine
Though, we may not be so tough to implement this way of shoot-all-references, and, besides, this doesn't work for references in other object's properties, but I think this may be a way to go for the solution. This may be the method for Jim's FoxWish self-euthanasia of an object.
After playing some more, I've changed the code to read like this:
y=create("custom")
y.addobject("dumb", "dummy")
x=y.dumb
y.dumb.releasereference
?type("x")
if type("x")#"U"
?? "isnull=",isnull(x)
endif
?type("y")
if type("y")#"U"
?? " isnull(y)=",isnull(y)
endif
?type("y.dumb")
if type("y.dumb")#"U"
?? " isnull(y.dumb)=", isnull(y.dumb)
endif
The class definition remained the same. In the debugger I saw the AInstance() doesn't catch the y.dumb as a reference. Tried some more, and it seems that AInstance() works for simple variables used as object references, while it doesn't have any idea of any references in object properties or container members. It actually returns 0 as reference count if there's no variable reference, i.e. can't even find itself. Too bad (using 5.0, no SP).