• home
  • Email: trainings@synapseindia.careers



What are new features in .Net Framework 4.5?

Jul 28, 2015

Microsoft .Net Framework has matured a lot over the past few years. New features and enhancements have been introduced aplenty to optimize it and make it fast, secure, more stable, and high perform-ant. Let us cover some new features in latest version of .NET Framework 4.5:

The dreaded Out of Memory exceptions

This is a dreaded error and can well become a nightmare for you. Out of Memory exceptions can terminate the flow of control of your application even when you have enough physical memory installed. Are you kidding? No way! Let me explain why this can occur and how this issue has been addressed in .Net Framework 4.5.

Objects created by the managed environment are stored in heap. Over a period of time the heap may become fragmented because of creation and removal of objects. Fragmentation refers to memory holes (free memory) that are scattered. In such a case, you would often observe Out of Memory exceptions if your application uses large amount of memory and because the runtime would be incapable of allocating space when and if needed even if there may be space available.

Sounds weird? Well, the sum of the memory holes may suffice for this request, but as these memory holes are scattered, the runtime cannot use them.

Compaction of Large-Object Heap on demand

The On-Demand Large Object heap compaction has been newly introduced to compact the heap and eliminate heap fragmentation. Compaction implies compacting all these scattered memory holes into one block. This feature is available (on-demand only) from .Net Framework 4.5.1 to mitigate the Out of Memory exception issues. To enable this feature, you need to set the LargeObjectHeapCompactionMode property.

Incidentally, this property can have one of two values: Default and CompactOnce. The former if set would ignore compaction of large object heap during a GC cycle. If you use the latter, the large object heap would be compacted during the next cycle.

Support for ADO.Net Connection Resiliency

You no longer need to write code to implement connection resiliency to establish idle or broken connections. .Net Framework 4.5.1 comes with this feature built in to re-create broken connections to the database.

Improved startup time: Profile optimization

Profile optimization is a feature that has been introduced in .Net Framework 4.5 that minimizes the application startup time. How does this work? A profile is a file that contains the methods the application would need at the time it starts. When the application starts, the Just in Time Compiler (JIT) runs in a background thread and across multiple processors to generate native code from the IL code.

Garbage collection enhancements: Server GC introduced

The managed environment of .Net uses garbage collection to clean up unused or unreferenced objects -- objects that are no longer needed. In the earlier versions of .Net Framework, the GC suspended the application threads when it was busy cleaning up the memory. This was a major performance bottleneck as your application had to wait till the GC finished its work.


With .Net Framework 4.5 this is no longer an issue; server GC has been newly introduced to facilitate cleaning of generation-two objects using a background thread and, hence, minimize the load on the main GC thread as the application threads are much less frequently suspended. With .Net Framework 4.5, background garbage collection is supported in both server and workstation GC. Concurrent garbage collection is also supported now; a dedicated thread performs the garbage collection when needed.

SynapseIndia (CEO: Shamit Khemka)