C# 窗口没有';等待X ms System.OutOfMemoryException后,没有响应

C# 窗口没有';等待X ms System.OutOfMemoryException后,没有响应,c#,wpf,mvvm,white-framework,C#,Wpf,Mvvm,White Framework,我已经为应用程序的一个功能实现了一个白色框架测试用例。 测试用例正在执行的功能类似于从应用程序的主屏幕,它将在单击主屏幕上的按钮后导航到另一个屏幕,然后在登录屏幕上,它将重复单击按钮50次,执行保存数据和读取数据的操作 测试用例的要求是检查应用程序的可靠性,在进行测试时,假设测试用例运行了用户输入的分钟数 CoreAppXmlConfiguration.Instance.BusyTimeout的值=用户输入的执行时间,以分钟为单位*60000+5000 下面是测试用例的代码 [TestMetho

我已经为应用程序的一个功能实现了一个白色框架测试用例。 测试用例正在执行的功能类似于从应用程序的主屏幕,它将在单击主屏幕上的按钮后导航到另一个屏幕,然后在登录屏幕上,它将重复单击按钮50次,执行保存数据和读取数据的操作

测试用例的要求是检查应用程序的可靠性,在进行测试时,假设测试用例运行了用户输入的分钟数

CoreAppXmlConfiguration.Instance.BusyTimeout的值=用户输入的执行时间,以分钟为单位*60000+5000

下面是测试用例的代码

[TestMethod]
public void TestcaseName()
{
  // Take memory snapshot
  Stopwatch sw = new Stopwatch(); // Stopwatch to compare time if it is equals 
                                  // or exceeds time enter by user.
  sw.Start();
  bool needToRepeate = true;
  While(needToRepeate)
  {
   // do white framework code which will execute functionality

   if(sw.Elapsed >= time enter by user in minutes)
   {
    needToRepeate = false;
    // Take memory snapshot
    sw.stop();
   }
  }
}
以下是找到的完整堆栈跟踪

TestStack.White.UIItems.UIActionException: Window didn't respond, after waiting for X ms ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(IntPtr dataPtr)
at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos()
at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_Threads()
at MS.Internal.Automation.HwndProxyElementProvider.System.Windows.Automation.Provider.IWindowProvider.WaitForInputIdle(Int32 milliseconds)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr)
at TestStack.White.UIItems.WindowItems.Window.WaitForWindow() in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\WindowItems\Window.cs:line 223
at TestStack.White.UIItems.WindowItems.Window.WaitWhileBusy() in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\WindowItems\Window.cs:line 184
--- End of inner exception stack trace ---
at TestStack.White.UIItems.WindowItems.Window.WaitWhileBusy() in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\WindowItems\Window.cs:line 191
at TestStack.White.UIItems.Actions.Action.Handle(Window window) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\Actions\Action.cs:line 17
at TestStack.White.UIItems.WindowItems.Window.ActionPerformed(Action action) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\WindowItems\Window.cs:line 254
at TestStack.White.InputDevices.Mouse.ActionPerformed(ActionListener actionListener) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\InputDevices\Mouse.cs:line 190
at TestStack.White.InputDevices.Mouse.Click(Point point, ActionListener actionListener) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\InputDevices\Mouse.cs:line 185
at TestStack.White.UIItems.UIItem.PerformClick() in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\UIItem.cs:line 265
at TestStack.White.UIItems.UIItem.PerformIfValid(Action action) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\UIItem.cs:line 242
at TestStack.White.UIItems.UIItem.Click() in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\UIItems\UIItem.cs:line 231
at TestStack.White.Bricks.DelegateInvoker.VoidActionInvokerWrapper.Call(Object[] args) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\Bricks\DelegateInvoker.cs:line 309
at TestStack.White.Bricks.DynamicProxyInterceptors.Process(IInvocation invocation, CoreInterceptContext interceptedContext) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\Bricks\DynamicProxyInterceptors.cs:line 21
at TestStack.White.Interceptors.CoreInterceptor.Intercept(IInvocation invocation) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\Interceptors\CoreInterceptor.cs:line 31
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.ButtonProxy.Click()
实际结果: 在连续7天运行测试用例时发生错误,将在第3天中断。记录的错误为“等待X毫秒后,窗口未响应”

其中X是用户输入的转换为毫秒的值

预期结果: 它应该运行测试用例,没有任何错误

我试图弄明白为什么OutofMemory异常是由white框架引发的

有谁能帮我解决这个问题吗


提前感谢

很明显,您有内存泄漏,无论是在您的代码中还是在您正在使用的框架中,如果没有实际的代码,都无法得知。我建议您尝试分析一下测试用例,看看是什么增加了内存。@gpro:非常感谢您的建议和快速响应,我对这个主题进行了研究,发现了一篇文章“”,文章中说,当测试用例数量增加时,白色框架会导致内存问题。但所描述的解决方案不可能在我当前的需求中实现。若你们有更好的解决方案,然后在文章中提到,请建议,这将是真的很有帮助。我通常使用Visual Studio内置分析器,只有在失败时才使用高级的。您可以从这里获得基本知识:。如果它不够强大,那么有更多的工具可用于更深入的检查。很明显,你有内存泄漏,无论是在你的代码中还是在你正在使用的框架中,都无法在没有实际代码的情况下得知。我建议您尝试分析一下测试用例,看看是什么增加了内存。@gpro:非常感谢您的建议和快速响应,我对这个主题进行了研究,发现了一篇文章“”,文章中说,当测试用例数量增加时,白色框架会导致内存问题。但所描述的解决方案不可能在我当前的需求中实现。若你们有更好的解决方案,然后在文章中提到,请建议,这将是真的很有帮助。我通常使用Visual Studio内置分析器,只有在失败时才使用高级的。您可以从这里获得基本知识:。如果它不够强大,那么有更多的工具可用于更深入的检查。