Is there a way of displaying the amount of memory used per-test within NCrunch?
We have an odd CI issue where some tests are using so much memory it's crashing the process, and we're trying to track it down. I was hoping to be able to show the rough memory usage per-test when running in NCrunch? It would help us narrow down where to look...
Remco NCrunch Developer
#15974
02 Feb 2022 12:10 UTC
Hi, thanks for posting.
We don't have anything built-in that can do this. Given that the tests themselves are your own code, perhaps it might be possible for you to engineer something into the tests themselves? For example, you could create a SetUpFixture that starts a background thread which monitors the amount of memory in use in the process. When the memory usage hits a threshold, it enumerates all threads in the process and captures the stack trace of each one, then writes this to a file on disk.
Something else you could try is to declare the NCrunch.Framework.IsolatedAttribute at assembly level in your test projects. NCrunch will then run each fixture in its own process. This might help reduce the data you need to sift through if you can identify a specific process that's eating more than it should.
We don't have anything built-in that can do this. Given that the tests themselves are your own code, perhaps it might be possible for you to engineer something into the tests themselves? For example, you could create a SetUpFixture that starts a background thread which monitors the amount of memory in use in the process. When the memory usage hits a threshold, it enumerates all threads in the process and captures the stack trace of each one, then writes this to a file on disk.
Something else you could try is to declare the NCrunch.Framework.IsolatedAttribute at assembly level in your test projects. NCrunch will then run each fixture in its own process. This might help reduce the data you need to sift through if you can identify a specific process that's eating more than it should.
Edited 02 Feb 2022 12:12 UTC
Unfortunately there are a number of xunit-based tests, so doing the SetupFixture equiv involves a bit of work.
I don't think NCrunch is the right tool for this job entirely, it was just a hope really to help track something down! Cheers!
I don't think NCrunch is the right tool for this job entirely, it was just a hope really to help track something down! Cheers!
Deleted post
#16377
14 Dec 2022 08:11 UTC
Deleted post
#18339
24 Sep 2025 06:06 UTC
Post a reply
Log in to reply.