C# Large objects and heap

后端 未结 2 456
太阳男子
太阳男子 2021-02-08 21:19

I am a bit confused about the storage of large objects within the heap.. Like at what size is the object cosidered large? What types are more likely to be treated as large objec

2条回答
  •  太阳男子
    2021-02-08 21:40

    This article has a lot of details, although you should be aware of changes coming in .NET 4.5 too.

    The only types which are likely to end up on the LOH are strings and arrays - because they're the only types which can basically be given a size at execution time. I'm not sure it's even valid to create a type with so many fields that it would end up on the LOH as a single object - it may well be, but I can't imagine it happening in reality.

    According to the linked article, the limit is currently 85,000 bytes. It's an implementation detail really though - you should rarely need to think about it.

提交回复
热议问题