Yes, I see the memory leak (in Windows Task Manager) when creating and deleting instances of Ifunction many times.
For every instance, The
id string is logged onto the global garbage list which is not emptied till the end of the program. Not much help for this mode of OOP.
The cleanest solution is to make
id a
bstring, then free it explicitly in the destructor, like you did before.
class IFunction
bstring id
sys address
declare function ptr f()
method toString() as string
return "f:" id "<" address ">"
end method
method constructor(id0 as string, sys addr0)
initialize id0,addr0
end method
method destructor()
frees id
end method
method initialize(id0 as string, sys addr0)
'method initialize(string id0, sys addr0)
#show id =id0
address =addr0
end method
method call()
@f=address
f()
end method
end class
function f1() as sys, label
'print "here"
end function
print "start"
string s
for i=1 to 1000000
new Ifunction fn("ABC",@f1)
s=fn.toString
fn.call
del fn
next
print @fn '0
PS: Wikileaks
If Julian Assange steps out of the Equadorian embassy, these chaps will arrest him immediately. The siege has cost 10 million pounds so far! Someone must be desperate.