XSystem not releasing XSet items added to factoryObjects collection


It appears there is a memory leak within XSystem, in that every time an XSet is created, it is added to XSystem.factoryObjects and never removed. (See http://xamsdk.codeplex.com/Thread/View.aspx?ThreadId=212960 for original discussion.)
The methods OpenXSet, CreateXSet & CopyXSet add the XSet to the XSystem.factoryObjects collection.
I'm not sure why they are added here, as they are also added to static XSet.xsetObjects within XSet constructor (& removed on dispose).
I'd suggest removing the 3 lines within the above methods. I have tried this & tested (using option 12 of TestHarness). I monitored managed memory objects (with dotTrace) and found no increase in managed objects after repeated calls.


gstuartemc wrote May 19, 2010 at 11:36 AM

There is a good reason for tracking them within the XSystem - you cannot close an XSystem that has underlying XSet objects open. By tracking them in the XSystem, we are able to “force close” any open XSets and thus prevent an error if the application attempts to close the XSystem.

The bug is that when an XSet is closed, it should be removed from the XSystem factory objects list. I have addressed this and will upload a fix shortly.

wrote May 19, 2010 at 11:40 AM

SteveC wrote May 19, 2010 at 11:34 PM

Graham, Thanks for your your quick responses and patch. much appreciated.

SteveC wrote May 20, 2010 at 2:52 AM

Hi Graham,

There is possibly a problem with th patch, XSystem.OpenXSet & CopyXSet are not setting xset.xsys. So when XSet.Close() is called xsys will be null and the good old “object reference not set to an instance of an object” will be thrown. :-)


wrote Feb 2, 2013 at 1:32 AM

wrote May 14, 2013 at 9:03 PM

wrote May 14, 2013 at 9:03 PM

wrote Jun 12, 2013 at 1:15 AM