10-30-2014 04:34 AM
Hi,
we develop a software in C# which uses the TestStand API.
we note that TestStand API allocates memory at the first execution of a TestStand sequence
All the memory of this first execution is not deallocate at the end.
why ?
Is it a problem with Active X technology ?
Is it a conserved memory for the next execution ?
Is it possible to not have this comportment ?
For information, we have deactivated the generation of the TestStand report.
Thanks for the answers
Best regards
11-03-2014 04:39 AM - edited 11-03-2014 04:40 AM
Hello,
According to your step configuration (Run Options » Load Option and Run Options » Unload Option), this could be the expected behavior. By default, TestStand loads code modules when execution begins, and unloads them when sequence file is unloaded - not at the end of sequence execution. The goal is indeed to keep loaded modules in memory for next executions.
To see if it is related to load/unload options, you can try
Best regards,
11-03-2014 08:38 AM
There is memory allocated when an execution is run for many different reasons. Please be more specific as to which memory you are referring. Choose one of the following (or add your own if I have forgotten one).
1) Memory used by result collection (to store results under Locals.ResultList while an execution is running). These are typically freed once the process model is done processing them typically for report generation or database logging. By default the process model processes them between runs of the mainsequence on the UUT. These results are also freed when the execution completes (i.e. stops running). If you are not using a process model or do not need results for specific steps or sequences you can disable result collection on a per-step, per-sequence, or global basis.
2) Memory used to keep the sequences and executions themselves in memory. These datastructures stay in memory as long as you have a reference to them. One additional twist with .NET is that you might not think you have a reference to them, but you really still do because .NET hasn't gotten around to garbage collecting the references yet. You can force garbage collection as follows with the following code:
public static void DoSynchronousGCForCOMObjectDestruction()
{
// To make sure activex refs are synchronously released
// we need to call GC.Collect() and GC.WaitForPendingFinalizers()
// at least twice, according to the following document:
// http://msdn.microsoft.com/en-us/library/aa679807%28v=office.11%29.aspx
// The reason we have to do it twice is that the the first call
// might just sweep the objects into generation 2 rather than collecting
// them immediately.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
}
3) Memory used by code modules being loaded. This memory is freed when the step settings on your code modules say to unload your modules, but the behavior is somewhat different depending on the adapter. Some adapters can unload code modules on a per-code module basis, but the .NET adapter can only unload code modules when all code modules and .NET objects created by the .NET adapter are no longer supposed to be loaded or referenced. That is because in .NET the only way to unload code modules is to unload the appdomain containing them. TestStand uses a single appdomain for the .NET adapter and unload that appdomain when all .NET code modules referenced by the adapter are unloaded and all .NET references gotten from those code modules into TestStand are no longer in scope.
Hope this helps explain things.
-Doug
11-04-2014 12:19 AM