From 7bd68dd17b80dea4910af04a9c602a304e854101 Mon Sep 17 00:00:00 2001 From: James Groom Date: Fri, 30 Aug 2024 23:09:41 +1000 Subject: [PATCH] Add 1 more link re: allocation limits --- C#-and-.NET-docs-supplement.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C#-and-.NET-docs-supplement.md b/C#-and-.NET-docs-supplement.md index 6bd3168..67f7ce4 100644 --- a/C#-and-.NET-docs-supplement.md +++ b/C#-and-.NET-docs-supplement.md @@ -9,7 +9,7 @@ Under .NET 8: - The largest 1D byte array is `new byte[Array.MaxLength]`, `Array.MaxLength` being hardcoded to `0x7FFFFFC7` or just under 2 GiB. (Would probably want to alloc in 1 GiB chunks to have nice code, maybe even smaller to keep the GC happy.) - The largest 1D struct array is `new T[Array.MaxLength]`. So its size is... unbounded since structs don't have a size limit apart from the stack size (and `[InlineArray]`'s 1 MiB cap). (TODO check there isn't an undocumented cap) - The largest *n*-D byte array is `UNK()` (`LongLength` is `0xUNK` or UNK GiB). -- All of that is on the managed heap. The default/global stack is OS-specific and cannot be changed (feature request to come): On Windows, it's 1.5 MiB [due to an oversight](https://github.com/dotnet/runtime/issues/96347#issuecomment-1871528297), and on Linux, it's inherited from the OS, typically 8 MiB. +- All of that is on the managed heap. The default/global stack is OS-specific and cannot be changed (feature request to come): On Windows, it's 1.5 MiB [due to an oversight](https://github.com/dotnet/runtime/issues/96347#issuecomment-1871528297), and on Linux, it's inherited from the OS, [typically 8 MiB](https://github.com/dotnet/runtime/issues/33622#issuecomment-599462300). - The stack size for threads can be [chosen at runtime](https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.-ctor?view=net-8.0#system-threading-thread-ctor(system-threading-threadstart-system-int32)), though as with all of this you may have an XY problem and should reconsider. Under Mono (x64 unless specified):