-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[F.Rq.] Some way to configure the size of the stack #107183
Comments
On Unix, you can set the default stack size this way:
On all OSes, but only for secondary threads, since the main thread stack size is set by the OS when launching the application and the runtime cannot influence it.
On Windows, you can also modify the stack size set in the host executable (if you build your app, you end up having YourApp.exe and YourApp.dll, the .exe is the host)
You can also specify the thread stack size when creating new threads in your code in the constructor of the thread ( |
Tagging subscribers to this area: @mangod9 |
@YoshiRulz is this sufficient for you or would you like something additional? |
My team develops on and builds for Windows and Linux, so I think we could use a combination of those 2 workarounds, but it still seems odd that there's no way to change the stack size for the main thread. edit: I maintain that a compile-time |
@YoshiRulz there are ways to change it for the main thread both on Windows and Linux that I've mentioned in my previous comment:
|
@YoshiRulz what's wrong with these ways? The default stack size for the main thread is something only the operating system can set, because it needs to be set before the process is launched and the application itself doesn't have any way to control it. |
As per my edit above, they're not cross-platform, and one is compile-time and one is runtime. If the runtime can't change its own stack size, perhaps it could spawn a new thread with the stack size specified in the assembly metadata (for example) and begin execution of the main method on that thread? |
Per discussions at #96347 (there is no official documentation†), the size of the default/global stack is fixed and differs between OSes.
ASP.NET devs can use the
stackSize
setting (only with IIS?) to configure it. I would like to do the same with a CLI or desktop app. A new API or an environment variable would also be acceptable for me.I would use this to decrease the size in order to root out stealthy bugs, but I can also see it being used to increase the size for some non-ASP.NET server or other high-perf use case.
See also:
† There seemed to be no official documentation for the stack in modern .NET, and info for .NET Framework and Mono was all over the place, so I've collected everything I've found here.
The text was updated successfully, but these errors were encountered: