Microsoft: Upgrade .Net for better garbage collection


Microsoft is encouraging developers to move to the 4.6.2 version of the .Net Framework, so they can benefit from significant changes to the garbage collector, which provides automatic memory management.

.Net Framework 4.6.2 , but Microsoft is now advising upgrades to take advantage of benefits in object handling. These changes were made in order to improve the framework’s performance and to allow the garbage collector to operate more efficiently, Microsoft said. Garbage collection enables developers to build applications without needing to free memory; it also allocates objects on the managed heap and reclaims objects no longer in use.

Version 4.6.2 removes a limitation in which an object and adjacent live data objects could not be moved when an object was reported as “pinned survived,” said Maoni Stephens, main garbage collector developer at Microsoft. “Starting with version 4.6.2, this limitation was lifted so we could compact away the adjacent live objects around pinned objects. In testing, we saw dramatic improvements of ephemeral collection time in scenarios where GC was artificially pinning a lot of objects.”

The new version also features more efficient use of free space with gen2 objects. Previously, the framework used a first-fit approach when compacting gen1 survivors into gen2 free list, which meant garbage collection-discarded spaces could not be used, leading to wasted spaces in memory. Version 4.6.2 introduced a bucketed free list where leftover free spaces are threaded into their respective bucket, Stephens said. Microsoft had to be very careful of the usage in the smallest bucket as there could be many of them.