05-03-2007 05:26 PM
I’ve noticed that the C# RTOI NI has released has a call to GC.Collect() in an idle event callback even though Microsoft recommends against doing this. I suspect that this is the only way for TestStand to free objects (ie. propertyObject) in the .NET environment.
In the sequence editor I get a warning message regarding objects not released correctly (See attached file). These are COM objects that do not derive from Idisposable so this no dispose method available.
1.) Is there a method other that calling GC.Collect() to free TestStand Objects from the .NET environment?
2.) Are there any improvements planned to correct this situation in future TestStand versions?
It seems as though it is possible to set the local object reference to nothing in TestStand after a call to a .NET assembly which seems to free up objects from that call.
3.) Does this actually free object references in TestStand?
4.) When the local object reference from a .NET call goes out of scope it doesn’t appear as though the TestStand objects get released correctly. So, what is the difference in setting a TestStand local variable representing a .Net object reference to nothing vs. simply allowing the variable to go out of scope?
Thanks,
Steve
05-04-2007 01:43 PM
05-07-2007 02:26 PM
05-14-2007 01:08 PM
Here is what I used to release sequence file objects in C#
private void ReleaseSequenceFile( SequenceFile SeqFile )
{
bool released = false;
while( !released )
released = _engine.ReleaseSequenceFileEx( SeqFile, 0x1 );
System.Runtime.InteropServices.
Marshal.ReleaseComObject( SeqFile );SeqFile =
null;}
Here is what I did for PropetyObjects:
The oParameter was a NI PropertyObject reference.
System.Runtime.InteropServices.
Marshal.ReleaseComObject( oParameter );oParameter =
null;Now, this was code I wrote a year or so ago...But, I also call GC collect. Even though MSFT discourages the use of forcing a GC, I feel it is necessary and not signifcantly taxing the resources for me to accomplish the release.
05-14-2007 03:14 PM
Toedwy:
That worked great.
Thanks,
Steve