NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory allocation and freeing

We have a teststand sequence which has a lot of looping and use of large arrays of containers. While running the memory usaged continues to rise and we recieve running low on virtual memory warnings. At the end of the sequence the memory usage does not clear. If it was a case of we've just got arrays that are too large then I could accept that and perhaps look at re-structuring the code for better dynamic memory use or buy more RAM but the fact that I have to actually close TestStand before the memory is freed up suggests to me that teststand is allocating memory and not freeing it up. Have I missed something?

Tried so far...

1. Edit -> Sequence file properties -> Load Option -> Load Dyanmically
2. Edit -> Sequence file properties -> UnLoad option -> Unload after sequence executes
3. Configure -> Model Options -> Discard results or disable results when not required by model
4. Configure -> Report options -> Disable report generation
5. Configure -> report options -> Disable report generation (unchecked), On the fly reporting (checked), Conserve memory... (checked)
6. "Looped steps" -> Run Options -> record results (unchecked)

Concerned that I had a dll with a memory leak I created a single statement stepped sequence with the following code...

SetNumElements(Locals.array,GetNumElements(Locals.array)+1),
Locals.array[RunState.LoopIndex] = 1

This step was looped 10,000 times.

Before...
Mem Usage 37,004 K
VM Size 28,128 K

After...
Mem Usage 42,280 K
VM Size 31,144 K

Also what are all the handles? In the actual code I end up with 1600!

Sorry it such a long post but I am trying to give you as much info as possible. Please let me know where I'm going wrong.
 
cheers
Mike
 
Software Details: TestStand  version 3.0
NI Hardware :
Other device
Driver Version :
Operating System: Windows 2000
0 Kudos
Message 1 of 4
(3,946 Views)
Hi,

If you are using the TestStand loop options, did you disable the option "Record Result of Each Iteration" of your looping step ("Loop Options" tab of the step properties) ?

Bruno
0 Kudos
Message 2 of 4
(3,933 Views)

Hi Mike,

I've had a look at your post, and you seem to have covered most settings in TestStand, when trying to work out where its coming from.

If you are using arrays to pass data around, then you could use a statement step to remove the elements from the array once you have finished with the part of the sequence that concerns those arrays. There is a function RemoveElements() which you can use to remove a number of elements from an array.

I've had a look at this with the example you suggested of using a statement to simply increment the number of array elements for each step run, and set the step to loop for 10,000 iterations. In the cleanup group of this sequence, I've included a statement step which uses this RemoveElements function to remove the number of elements currently in the 'Locals.array', (using the GetNumElements() function to know how many exist).

Using this, when I run the sequence, I see the memory increase as it increments the array, but at the end of the sequence I can see the memory is released and the memory usage figure drops to (almost) the same as it was before running the sequence. Without this step in the cleanup group - I see the same behaviour of the increased memory not being released.

I've attached the sequence I created to the post, take a look at this and let me know if it resolves the concerns you have, if not then let me know, and I'll take a further look into this for you.

Regards

Hannah
NIUK & Ireland

 

 

0 Kudos
Message 3 of 4
(3,906 Views)
I also wanted to point out that in 3.0, there was a problem with the RemoveElements function that was not properly freeing the memory.  I would recommend using SetNumElements to reduce the size of an array rather than RemoveElements.  This problem was corrected in TestStand 3.5.
 
Allen P.
NI
0 Kudos
Message 4 of 4
(3,896 Views)