Description
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.1.1, 10.8.4
Bug summary
During start up, Umbraco will read from/write to NuCache (BPlusTree) by either reading from the local .db files, or writing to the local.db files as it reads the cmsContentNu in order to make the content and media available to the content cache.
Specifics
The Serializer used by Umbraco NuCache code does not do any pooling of Char[]'s or strings. I've raised a pr to Umbraco-CMS that fixes this #15808.
Additionally, the CSharpTest.Net.Collections library allocates byte arrays and MemoryStreams when it reads/ writes. I've raised umbraco/CSharpTest.Net.Collections#2 to pool the byte[]'s and memory streams. If this is merged, then another pr can be raised for Umbraco-CMS that would update this package.
Steps to reproduce
Publish a large number of documents / media with large rich text values (Think 10k + blog posts).
Stop Umbraco
Run dotMemory on umbraco and take a snapshot of memory once umbraco renders the home page.
Click memory allocations for the snapshot.
You will observe a large number of bytes allocated to byte[]'s and char[]'s (potentially gigabytes, for a 100k blog site, this was on the order of 10s of gbs, while the nucache db files were only ~200mb).
Expected result / actual result
I would expect that only some fixed buffer size would get allocated for the byte and char arrays be allocated and reused and only the memory needed for the deserialized content be allocated. Fast startup of Umbraco to render the first page.
Actual result is 10's of gigabytes of memory allocated at start up, long garbage collector pauses as the process runs out of memory, and a slow startup.