NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to understand the life time of object references (LabVIEW OOP)

Solved!
Go to solution

In teststand I'm using the batch model. The workspace consists of several sequence files each containing several sequences/callbacks. Number of sockets = N

 

In the pre-batch callback, for each test socket,  I call a LabVIEW class constructor method which does the following:

 

-Instantiates a LabVIEW class (name: NXP)
-In the constructor: instantiate a .NET class (name:NXPSSH) and store its reference in a property. 
-Return reference of NXP.
//So this LabVIEW object (NXP) has a reference property to a .NET object (NXPSSH). 

I assign the returned reference to an object reference in 

ModelData.TestSockets[i].UUT.AdditionalData.NewSubProperty("Reference", PropValType_Reference, False, "", 0),
ModelData.TestSockets[i].UUT.AdditionalData.Reference = Locals.NXPReference

At this point each test socket has a reference to one LabVIEW NXP object which in turn has a reference to one .NET NXPSSH object. 

 

My questions:

  1. Saving the NXP reference in the testsockets additional data would keep the NXP and NXPSSH references alive/valid during the whole test execution, i.e. after prebatch finishes executing. Correct?

When I test my application, 80% of the time it works well, but sometimes I get invalid references when I call the NXP methods which call the NXPSSH methods. It seems to me that the reference to the NXPSSH object somehow gets deleted/invalid.  Perhaps because they are in separate application domains. I know that LabVIEW deletes all the references when the caller VI finishes executing. But in this case I'm literally storing the NXPSSH refence object in a class property. 

0 Kudos
Message 1 of 2
(2,203 Views)
Solution
Accepted by topic author aan1

 So I am not familiar with the .NET constructor you are referring but here is my experience with what you are doing.

To keep a reference valid you have either hold it open in TestStand and pass it to each VI that needs it or use the concept used in Actor Framework and create a VI that's holds the reference open and then send a message to the VI that closes it at the end.

I have worked with a customer that uses a VeriStand for TestStand add-on that uses .NET and in this ad-hoc each step obtains the VeriStand reference so this makes me assume .NET is doing some type of clean up which is causing your reference lose.

If you can provide a bit more detail as to what you are doing I may be able to help you a bit more with the solution.

David Wilt
The New Standard LLC
0 Kudos
Message 2 of 2
(2,177 Views)