Releasing leaked objects

I recently ran into a bug (39311) with the XML classes where if the xml.load(s) fails for some reason the xmlException object never get released… for example do this:

dim s as string
s = “” // or any invalid xml string
dim x as new xmlDocument
try
x.load(s)
catch e as XmlException
// do something
end try

Each time you run this code the Runtime.ObjectCount increases by 1… even after x is destroyed… If you look at the globals-runtime-contents, you will see all the unreleased objects.

So my question: Is there anyway to release these objects? I looked at introspection but that does not seem to help.

Thanks,
Jim

Try setting e to nil, but that’s about it. You have no control over the internal reference counting.

Hi Kem…

Thanks for the response… but I tried that and it does not help…

Yes, I can reproduce. Unfortunately, there is nothing to do until Xojo fixes it unless you can find a way to avoid the exception entirely.

I’m having similar issues with the Web framework.

I’ve dealt with this type of issue to. Since Runtime.ObjectCount was not according my expectations, I felt insecure about memory leaking. And still …

I recall that the plugin SDK offers retain/release functions for Xojo objects. So, if you can get to those SDK functions somehow, e.g. if someone made a plugin for that (may MBS already does), then you can release the object. There may be other ways to get to these internal functions as well. If you’re building for OSX, for instance, you might be able to use a declare against the framework or runtime dylib and get to the function if you know its name.

The best solution I have is to make sure the string is actually valid encoding represented in the declaration at the top of the file… make sure the number of “<” and “>” are the same… but doing that is going to slow things down…

Other ideas are appreciated.

Oh please don’t do this. Playing with fire to fix a small memory leak is a bad idea and will come back to bite you when the bug is fixed.

Wouldn’t a simple wrapping in “#if RBVersion <= 2015.02” deal with that?