-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.OutOfMemoryException running NET6 unit testing with Console.Runner 3.16.3 #1352
Comments
Can you try with 3.15.4. That is the version we use in the adapter, and then what is used in dotnet and Visual Studio |
I get the below error. It seems it does not support NET6.
|
@OsirisTerje Support for Windows Forms was one of the things added in the 3.16 series. I think you may need to merge changes made in 3.15 and 3.16 into a new release. |
@CharliePoole Thanks! @ilCosmico Any chance you could provide a small repro for this? |
@OsirisTerje it's very difficult because, as I wrote, it happens randomly when running about 2600 tests. |
@ilCosmico Way back I had a need to create a huge amount of tests, and I used a .tt script (a T4 template). You could possibly use the same approach, have a look at https://github.com/OsirisTerje/NUnit.VisualStudioAdapter.TestPrograms/tree/master/TestNUnitMultipleTest/NUnitTest1 |
@OsirisTerje I was able to isolate a bunch of tests for reproducing the issue, but the whole package I can share with you is cca 15MB so I prefer to share it here. Command line As I wrote, when I run it via the command line it gives the below error |
I do need to see the source code for this, otherwise hard to debug it. |
Do you mean the source code of UnitTesting.dll? In the meantime, please download the content of the link and let me know if you are able to reproduce the issue on your machine too. |
I have done that, but I dont need to doubt your findings. In orderen to figure out what is happening here, i need to see the sourced code of what you're trying to test. Preferably a repro. |
Ok, here you can download zip file containing also src folder with the source code of the tests. |
@OsirisTerje did you download the project? Is it what you needed to investigate the issue? |
Yes, I did, and I did experience an OOM after 6 minutes run, in a file CreateNewEyeshotControl. The major thing here is that there are a lot of calculations being done, and at the same time the UI is present. That doesn't seem like a good choice, and will stress the system further. Looking at the memory consumption, the memory is being deallocated too, but I did see peaks at around 1GB memory. There might be higher peaks and then the question is what that comes from. This might come from anything really, and in particular, any winform or WPF involved here will be high memory objects. When the OOM happened the memory consumption was only around 400 MB. When the test code, the UI code and the simulation (?) algorithm (?) (assuming a bit here) is intermixed like this, It is hard to say what is causing what. I don't see any NUnit code in the OOM stacktrace. Just to be clear, I run this in Visual Studio, so the console runner is not involved, this is the adapter and engine only. And, looking at the stacktrace I see that it is using the MSTest adapter, not the NUnit one. That said: I would suggest that you simplify this code:
In short Divide and Conquer! |
Hi @OsirisTerje , thanks for the feedback. I prepared a new project without MS.TestAdapter and console.runner as suggested, but I get the same issue. Simulation is a WinForms custom control for which I need to perform tests, for this reason, I can't split testing with UI, sorry. Last but not least, please, don't forget that the main reason for the opening of this issue is that the same testing code run in Net Framework works like a charm. |
Since the OOM happens regardless of whether you run with NUnit or MSTest, it is not a problem in the test system/test frameworks. It obviously do have something to do with the framework you run, since it works in Net Framework. You need to run this with a memory debugger and diagnose from there. |
Ok, thanks for pointing me in the right direction. |
@OsirisTerje I've managed to identify the cause behind the out-of-memory issue. It turns out to be a known bug in .NET6, which has already been documented here. P.S. If you could spare a moment, your upvote on the issue would be greatly appreciated as well. Thank you! :) |
I'm running approximately 2600 unit tests for my custom control in both NetFramework 4.7.2 and NET6 via TeamCity.
With net472, all works fine.
However, I encountered issues with net6. Initially, I tried using Console runner 3.16.2, but I received the error

System.NotSupportedException: Cannot read resources that depend on serialization.
This error can also be reproduced when running tests on my local machine.
I then attempted to use the latest version, v3.16.3, and it seemed to work fine until I encountered an

OutOfMemoryException
after approximately 10 minutes (it does not crash always with the same test).When running the single test, it succeeds, but running all the tests on my local machine gives the

System.Net.Sockets.SocketException
instead (the same described here)The command line used is:
"C:\Users\xxx\.nuget\packages\nunit.consolerunner\3.16.3\tools\nunit3-console.exe" UnitTesting.dll --where cat!=Wpf --labels=BeforeAndAfter --trace=Error
Unfortunately, I can't run with the --inprocess flag due to the reasons explained here.
The text was updated successfully, but these errors were encountered: