I started getting this error randomly when running all test within visual studio 2019. 300 test pass and 700 test fail with this exact same error. Everyone else on my team can run all test on the main branch and all tests pass. 700/1000 of mine fail with: Error: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown..
-
sounds like some memory is not released. maybe some objects should be disposedurlreader– urlreader2020-08-24 22:43:08 +00:00Commented Aug 24, 2020 at 22:43
-
4Perhaps you should sync up with your teammates to see what you're doing differently than them. This doesn't sound like an answerable question unless you can get more details.littlerufe– littlerufe2020-08-24 22:46:29 +00:00Commented Aug 24, 2020 at 22:46
1 Answer
Assuming your machine isn't actually a 32-bit machine, it's possible that you've changed your build to target 32-bit environments. That would leave you with only 2 GB instead of the usual 4 GB.
It's also possible that your memory is heavily fragmented, which apparently can leave you actually having less memory than the total available.
See C# : Out of Memory exception for more on those points.
But ultimately I think the real problem is that one or more of your tests is probably leaking memory. You may be the "canary in the coal mine": the first person to experience the ill effects of something unhealthy in the code base that your whole team shares. Running your team's unit tests shouldn't push the limits of a system's memory. I would work with your other teammates to see if you can track down likely culprits. There are tools for memory profiling and such that should help.