How to Fix 'Out of memory exceptions' in desktop application tests using CodedUI

504 Views Asked by At

I'm working on CodedUI(VS2015) for testing a windows application. I have around 318 test cases that are executed using the Ordered test. The script will execute and show how many test cases failed or passed but for the last few executions, execution are blocked in between. Complete execution is not done and Out of memory exeption is shown in stack trace. Each time I execute script is stopped at different test cases.

This issue exists for all versions of the windows application now. Tried executing in 8GB as well as 16GB RAM configurations, still the issue was there.

Expected: Script should either pass or run.
Actual: Result29 Message:   Error calling Initialization method for test class
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

I am using ordered test for script execution and the scripts are failed in between. previously scripts were running properly.

Stacktrace: please find the stacktrace got after execution. I got many exceptions like this after the test run.

Result148 Name: 290- TC_747174_Cash_A_Check_DataValidation_CheckID_OnUsDetails_1 (cashacheck2) Result148 Outcome: Failed Result148 Duration: 0:00:00.0245286 Result148 StackTrace: at System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark& stackMark) at System.Threading.Thread.Start(StackCrawlMark& stackMark) at System.Threading.Thread.Start() at Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaWorker.StartWorkerThread() at Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaTechnologyManager.StartSession(Boolean recordingSession) at Microsoft.VisualStudio.TestTools.UITest.Framework.UITestPluginManager.<>c__DisplayClass1_0.b__0(UITechnologyManager manager) at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.b__1() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask) at System.Threading.Tasks.Task.<>c__DisplayClass176_0.b__0(Object ) Result148 Message: Error calling Initialization method for test class UltraDataAutomation.TestCases.CheckList_MemberTransactionsFeature: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

1

There are 1 best solutions below

4
On

There can be many possible causes, for example maybe you're allocating memory inside loops and not freeing it up properly. Same problem can happen if you are opening many data connections and not closing/disposing them properly.