-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix stackalloc in a loop introduced by #32025 #32375
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
Fix stackalloc in a loop introduced by #32025 #32375
Conversation
|
This feels like an analyzer warning... Though of course there are cases where it would be fine. |
|
@jkotas I was not aware that using stackalloc in a loop is a mistake. Why is that so? |
Yes, it was noted in #30740
It allocates a new chunk of memory every time it is executed. The memory is released only once the method exits. |
|
Do we know why it only affected macOS? Are our default stack sizes different? Do we align or size stackallocs differently? Etc. |
|
Yes, the default stack sizes differ between different OSes. |
My surprise is that I was under the impression Linux (most distros) was significantly larger than Windows. This suggests macOS is significantly smaller. Just looking it up now, seems the default size on macOS is indeed 512K. |
|
Yep, it is not the first time that this came up. E.g.: #12088 (comment) |
Fixes #32374, fixes #32367