Micro blogpost : Non GC heap objects
Disclaimer: This article is based on my current knowledge and understanding. If you have any query or see any improvement, please mention in the comment section
Languages like C#, Java , Golang have garbage collector( GC) to perform automatic memory management. In most cases, GC works great with default settings however if you have a specific high performance scenario, one can tweak the GC to work accordingly since GC pauses can affect performance of the application. One sureshot way to eliminate GC pauses is to eliminate any allocation on GC - heap so GC is not triggered to perform any work.
In .NET 8, string constants are getting special treatment. They will get allocated on non GC heap so string object is free from GC and won’t be moved by GC so JIT will directly bake address of string object into assembly and we will get performance benefit. Below code demonstrates the above concept.
~ Happy coding