Why would a Dispose() and DELETE OBJECT combo generates Inva

Posted by jquerijero on 19-Dec-2014 16:04

I have a code pattern that looks like this;

NEW someInfragisticsObject;
someInfragisticsObject:SUBSCRIBE(someEventHandler);

/* Do something */

someInfragisticsObject:UNSUBSCRIBE(someEventHandler);
someInfragisticsObject:Dispose();
DELETE OBJECT someInfragisticsObject.

After running the code block several times, I get an Invalid Handle error. Any ideas?

All Replies

Posted by Lieven De Foor on 24-Dec-2014 05:00

I've seen similar problems. It looks like the Dispose causes the .net side of the object to be (forced) disposed, but the proxy ABL object on the AVM side isn't always deleted as well...

You *should* never need to write a DELETE OBJECT for a .net object; simply clearing the reference *should* cause the garbage collector to release any resources.

I've written a Disposer class to clean up a Ribbon and all its contained/referenced Infragistics objects, as without it we've had huge memory leaks with Infragistics Ribbons. The Disposer mainly iterates over all RibbonTabs/Groups/Tools and calls Dispose() on them. Afterwards the objects are deleted using DELETE OBJECT, only when the handle is still valid...

This thread is closed