Base solution for your next web application
Open Closed

System.OutOfMemoryException when running all tests #5507


User avatar
0
JapNolt created

I am getting a System.OutOfMemoryException when running tests. I've had it happen both on my dev machine and in my build pipeline in VSTS. It happens when I run all the tests but if I run a failing test by itself, it works. If I watch testhost_x86.exe memory consumption, I see it steadily increase. I first had this happen in my main project so I downloaded a clean project, duplicated the built-in tests several times, and the problem has occured. I used JetBrains dotMemory to monitor memory usage and it appears that when the exception occurs, most of the process's memory is unmanaged memory.


4 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    First time hearing this exception in out of box unit tests. As I understand, the first time the tests are running without issues. But if you repeat running all unit tests, you get this exception. Right? Are you running the tests on Windows or MAC machine? And specify your AspNet Zero version.

    PS: check <a class="postlink" href="https://github.com/xunit/xunit/issues?utf8=%E2%9C%93&q=is%3Aissue+OutOfMemoryException">https://github.com/xunit/xunit/issues?u ... yException</a>

  • User Avatar
    0
    JapNolt created

    No, let me explain in more detail. I am running on a Windows machine. AspNetZero 5.3 AspNet Core/Angular merged project running on .Net Framework.

    In our solution, we've been slowly adding tests and recently the tests started randomly failing. I couldn't find anything odd in our tests other than the amount of tests. I'm also suspicious it has something to do with db work since our tests hit the db pretty hard.

    To replicate the issue I downloaded a clean 5.3 AspNet Core/Angular merged project, since that's what we're still using. I never have the issue running the tests out of box. But if I duplicate the out of box tests about 7 times (copy/paste/change test method name) so that there is a great volume of tests, the problem starts happening. I especially picked tests that hit the db, since I assumed that is the primary user of unmanaged memory.

    BTW, even running tests in a clean project (without test duplication), you will see memory consumption slow increase.

  • User Avatar
    0
    alper created
    Support Team

    Could you pls open a GitHub issue for this one <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/new">https://github.com/aspnetzero/aspnet-ze ... issues/new</a>

  • User Avatar
    0
    JapNolt created

    Issue created here: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/1570">https://github.com/aspnetzero/aspnet-ze ... ssues/1570</a>