WinForms application and Memory "leaks".

Nov 4, 2010 at 8:51 AM


We are playing with an idea to use TestAPI based scripts for user actions simulation during quite a long time and tracking memory consumption upon those actions.

Note: that is not a load or stress test, just a long time operations simulation.

So, we have a WinForms application under test and the scenario as follows:

1. Launch AUT by the script (TestAPI's OutOfProcess Application);

2. Launch Perfmon, start corresponding counter log;

3. Let the script to run and perform an action:

  a. click a button;

  b. wait for the dialogue window is visible;

 c. click [Ok] to close the dialogue;

 d. Wait for some time;

 e. Repeat the steps for several hundred times.

After the run we investigate Perfomon's counter log (and TestAPI's MemorySnapshots collection as well).

Both Perfmon log and MemorySnapshots show that AUT's Private Bytes and Working Set counters constantly grow during the script run.

Confusing point here that when the scenario is repeated manually (having practically the same delays)  - Private Bytes and Working Set counters don't grow.

At the first glance it looks like GC  is not working then we use the script and it does work when we use manual run.


Win XP SP3

VS 2010 (.NET 3.5)

TestAPI v 0.4

NUnit 2.5.


Could you please give a clue on that?

Thank you in advance!

Nov 4, 2010 at 3:35 PM


So far, we found some information at

Seems like AutomationPeers are counted as a part of Private Bytes and there is no way to distinguish memory consumed by AUT itself and its AutomationPeers, therefore we get a false alarm.

Nov 4, 2010 at 5:25 PM

Yep, if you use UIA you will see that. You should not see a constant grow though.