BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Large Object Heap And .NET GC Improvements

| by Roopesh Shenoy on Oct 12, 2011. Estimated reading time: 1 minute |

.NET Developers writing memory intensive applications would have seen several problems with Large Object Heap allocation and run into out-of-memory exceptions, even when the collective memory seems to be quite sufficient. .NET Framework 4.5 promises improvements in this area, with better LOH management and lesser fragmentation.

The CLR manages two separate heaps for allocation, the small object heap (SOH) and the large object heap (LOH). Any allocation equal to or greater than 85,000 bytes goes on the LOH. You can read more about the differences between the two heaps in these articles. Due to the performance tradeoffs in LOH, applications with large memory requirements such as heavy image processing face fragmentation and OutOfMemory Exceptions even before using the full memory limit.

There were already some improvements from .NET 3.5 to 4.0 in terms of total memory allocated. In one of the comments to the above issue, Brandon Bay, lead program manager for GC in .NET Framework, says –

Based on the example provided, we were able to allocate nearly 23 times as much memory before running out of memory on the large object heap going from version 3.5 to version 4.

and now .NET 4.5 seems to build on it –

In .NET 4.5, we made two improvements to the large object heap. First, we significantly improved the way the runtime manages the free list, thereby making more effective use of fragments. Now the memory allocator will revisit the memory fragments that earlier allocation couldn’t use. Second, when in server GC mode, the runtime balances LOH allocations between each heap. Prior to .NET 4.5, we only balanced the SOH. We’ve observed substantial improvements in some of our LOH allocation benchmarks as a result of both changes

You can read Brandon’s full post about more details. To learn more about how the .NET Framework’s Garbage Collector works, you can refer to the MSDN Documentation as well as this article by Andrew Hunter

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and dont miss out on content that matters to you

BT