How do you change default stack size for managed executable.net

前端 未结 1 661
予麋鹿
予麋鹿 2020-12-11 07:18

We have discovered that one of our auto generated assemblies is throwing a StackOverflowException on new(). This class has (bear with me please) 400+ simple properties that

相关标签:
1条回答
  • 2020-12-11 07:44

    You can use editbin to change the stack size for the executable. You can't do this in app.config as far as I'm aware.

    Another option (also mentioned on that page) is to create a new thread with the "right" stack size. The page mentions the pros and cons of this approach.

    I'd be surprised if just setting 400 properties in a constructor was the cause of the problem though... that's going to be one big stack frame - but unless you've got several big stack frames on the stack, I would expect it to be okay. The other possibility is that you've got endless recursion somewhere :)

    EDIT: An alternative suggestion...

    Presumably you have a lot of local variables in this constructor? (Otherwise it shouldn't take up any more stack than any other call.) Is it possible to split the constructor into multiple methods, setting (say) 20 fields per method? That will be tricky if the fields are read-only, admittedly.

    If you could give us an idea of what the constructor looks like, that would help a lot. You might also want to use ildasm to see what it claims the stack size will be for that constructor.

    Just to check, this is a class rather than a struct, right?

    0 讨论(0)
提交回复
热议问题