System.StackOverflowException error

  • Thread starter Thread starter Silvers11
  • Start date Start date
S

Silvers11

Guest
Hello,

I have a question about the below code. When I run this code, I get the error:

System.StackOverflowException

I can see that the lines that causes this are:

Span<Vector128<byte>> counts = stackalloc Vector128<byte>[3];
Span<Vector128<UInt64>> sum64 = stackalloc Vector128<UInt64>[3];

Now I need to declare those Vectors in each loop as they are needed for logic that comes under in the loop.

I am not sure what the correct way is to declare those in the loop. It seems that the stack is added with those memories in each loop? Even that it seems that they should be destroyed and redeclared in each loop?

Thank you




public unsafe static void GetfsWithgIndexes11()
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
unsafe
{
for (int T = 0; T < 89020; T++)
{
Span<Vector128<byte>> counts = stackalloc Vector128<byte>[3];
Span<Vector128<UInt64>> sum64 = stackalloc Vector128<UInt64>[3];

//A lot of code here that needs: counts and sum64

}
} //unsafe
}

Continue reading...
 
Back
Top