NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand and Memory Usage

Solved!
Go to solution

I have a pretty fundamental question, but I'm curious what is going on when I assign a string to a string in TestStand.

 

If I were to do the following:

 

Locals.String = Locals.String_2

 

Did TestStand copy the string or are the strings pointing at the same location? Is there a way to reference the same location if the strings are being copied?

0 Kudos
Message 1 of 2
(2,965 Views)
Solution
Accepted by topic author kevin.key

TestStand strings have copy on write behavior. What that means is that when you do an expression like you have written, a copy isn't actually made yet, but if either variable is later modified, then a copy is made at that time. From the user's point of view it is no different that if a copy had been made immediately when the assignment was done. The only difference is in memory usage.

 

NOTE: If what you really want is to have the variables share a string so that if it's modified in either place it will effect the value of both, you can either use an object reference to point to the string, or create an alias variable to the original string. You can create an alias variable by dynamically creating it using the SetPropertyObject API along with the options (PropOption_NotOwning | PropOption_InsertIfMissing)

 

Hope this helps explain things,

-Doug

Message 2 of 2
(2,952 Views)