Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
ericschmidt
#1 Posted : Wednesday, September 19, 2018 12:11:34 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Hello,

I have an application where I have a few layers of abstract base classes. I need to test some functionality that uses reflection within one of the base classes, so I need to create a dummy concrete type for my tests. However, once I define the class to implement the abstract class, NCrunch immediately fails with a System.OutOfMemmoryException. I'm having difficulty understanding what would cause this. Here is the full message that gets output for the project.

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at _Mono.Collections.Generic.Collection`1..ctor(Int32 capacity)
at _Mono.Cecil.Cil.CodeReader.ReadCode()
at _Mono.Cecil.Cil.CodeReader.ReadFatMethod()
at _Mono.Cecil.Cil.CodeReader.ReadMethodBody()
at _Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
at _Mono.Cecil.MethodDefinition.<>c.<get_Body>b__40_0(MethodDefinition method, MetadataReader reader)
at _Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at _Mono.Cecil.MethodDefinition.get_Body()
at nCrunch.Compiler.CecilReflection.CecilMethod.get_HasBody()
at nCrunch.TestExecution.Frameworks.DefaultClassMethodDescriptionLocator.ExtractClassMemberDataFromType(ReflectedType type, Boolean hashAllMethods)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.(ReflectedAssembly , IDictionary`2 , TestFrameworkDescription[] , Boolean )
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.ExtractClassMethodData(TestFrameworkDescription[] applicableTestFrameworks, IDictionary`2 codeFileIDsByFilePath, Boolean hashMethods)
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters , FilePath , BuildOutput , DirectoryPath[] , FilePath[] )
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )

Do you have any suggestions on what I could do to try to figure out what is causing this issue?
Remco
#2 Posted : Wednesday, September 19, 2018 1:54:00 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting!

There's a couple of possibilities here. The first is that it could well be the structure of your assembly is such that it's making NCrunch's IL analysis system particularly hungry. This could happen if, for example, you have a very large number of deeply nested methods. In such a situation, it may be sufficient to just set your Build Process CPU Architecture to x64, thereby increasing the available memory for the routine involved.

If that doesn't solve the issue, then there's a likelihood that you've managed to construct an IL structure that is either erroneous or NCrunch otherwise doesn't know how to handle. It might be possible to work around such a situation by changing your code structure, or changing the Impact Detection Mode setting to WatchText. If you're able to share a code sample that can reproduce such a problem, we should be able to fix it in NCrunch itself. You can submit small code samples through the NCrunch contact form.
ericschmidt
#3 Posted : Friday, September 21, 2018 12:30:22 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Thanks for the suggestions. We were already using the WatchText Impact Detection Mode because there are some referenced assemblies that were obfuscated and causing NCrunch to fail when using the CompareIL. After changing the Build Process CPU Architecture, the message changed slightly for me, however it still didn't point me to where the issue might be. I've pasted the new error message below.

I've found that if I declare the dummy concrete type in a separate (non-test) project NCrunch can execute successfully. I also had a coworker try implementing the same scenario I'm trying and he was getting a different message, but I never got what that message was. I'll try to get back with him tomorrow to see if he can give me the exact error message he was receiving. As for submitting code samples, I can try to put something similar structure wise to what we've got, but the project has gotten so big now that it might take me a while to get something put together. Even then, without having an idea of what might be causing the issue I'm not entirely sure what all would be needed. Is there any way for me to debug NCrunch to try to find out how far it is getting until it crashes?

System.OutOfMemoryException: Array dimensions exceeded supported range.
at _Mono.Cecil.Cil.CodeReader.ReadCode()
at _Mono.Cecil.Cil.CodeReader.ReadFatMethod()
at _Mono.Cecil.Cil.CodeReader.ReadMethodBody()
at _Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
at _Mono.Cecil.MethodDefinition.get_Body()
at nCrunch.Compiler.CecilReflection.CecilMethod.get_HasBody()
at nCrunch.TestExecution.Frameworks.DefaultClassMethodDescriptionLocator.ExtractClassMemberDataFromType(ReflectedType type, Boolean hashAllMethods)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.(ReflectedAssembly , IDictionary`2 , TestFrameworkDescription[] , Boolean )
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters , FilePath , BuildOutput , DirectoryPath[] , FilePath[] )
at nCrunch.Compiler.RemoteBuildRunner..()
at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
at nCrunch.Compiler.RemoteBuildRunner.(ComponentBuildParameters )
Remco
#4 Posted : Friday, September 21, 2018 1:20:27 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for these extra details.

The most likely source of these problems is the obfuscated reference assemblies. Obfuscated assemblies don't adhere to normal conventions (sometimes they actually fail a PEVerify check). This is deliberate as obfuscators are designed to prevent exactly what NCrunch is now doing - taking the code apart statically to analyse it.

NCrunch will bridge its IL analysis into the obfuscated reference assemblies if they contain types that are necessary for the deconstruction of code elements inside your test project. For example, your test project might make use of a method parameter declared inside the obfuscated assembly. In such a case, it's possible that the IL analysis will try to take apart the obfuscated assembly and will explode. It's impossible to really understand the behaviour here without a way to reproduce it (which I appreciate is not an easy thing to narrow down).

Sadly we don't have any diagnostic features inside the IL reader at the moment, so there's no way to inductively know which code element is causing the exception you're receiving. Extracting and commenting out the code in your test project is probably the most effective way to isolate this issue.
ericschmidt
#5 Posted : Friday, September 21, 2018 6:03:17 AM(UTC)
Rank: Member

Groups: Registered
Joined: 12/30/2016(UTC)
Posts: 18
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I'll try to get un-obfuscated assembly versions and see if replacing things point anywhere. I'm not entirely sure how that would be the problem just by adding in a new class if NCrunch was already setup to use the WatchText option.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.044 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download