Paul Krill
Editor at Large

Microsoft: Upgrade .Net for better garbage collection

news
Jan 26, 20172 mins

Microsoft urges developers to switch to .Net Framework 4.6.2, which was released last summer

garbage collection trash truck
Credit: Angelo Tsirekas

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 was released late last summer, 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.

“We also worked on a policy of which bucket to try as we didn’t want to lengthen the gen1 collection time much by spending more time in searching for a usable free space,” Stephens said. “We want to stay doing background GCs as much as possible in order to be more efficient at consuming free spaces.”

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author