With a managed application, blocks of memory are allocated on the managed heap. (The heap is the part of memory that is used to store objects, as opposed to the stack, which is used to store references to objects— more on heap and stack later.) The GC keeps track of the referenced objects on the heap and automatically frees up the memory allocated to a specific object when it goes out of scope. Calling the GC programmatically is possible by invoking the method System.GC.Collect. However, this is not recommended because it is not guaranteed that it will destroy your objects. It is best to focus on the business logic and let the CLR determine the right time for garbage collection.
A blog about Latest Technology News, Technology Videos, Computer Tips, Web Programming, Technology Events, SEO and further IT topics.
Wednesday, November 10, 2010
The .NET Framework - Garbage Collection
One of the most important benefits of using managed applications is the use of the garbage collector (GC). The role of CLR does not end after compiling the IL code into native code. In fact, the CLR is responsible for managing memory during the code execution. It assures that the memory used by the program is totally freed up after the program exits. With unmanaged applications, programmers are responsible for managing the memory and resolving problems that might occur if a block of memory is left allocated after the program ends.
With a managed application, blocks of memory are allocated on the managed heap. (The heap is the part of memory that is used to store objects, as opposed to the stack, which is used to store references to objects— more on heap and stack later.) The GC keeps track of the referenced objects on the heap and automatically frees up the memory allocated to a specific object when it goes out of scope. Calling the GC programmatically is possible by invoking the method System.GC.Collect. However, this is not recommended because it is not guaranteed that it will destroy your objects. It is best to focus on the business logic and let the CLR determine the right time for garbage collection.
With a managed application, blocks of memory are allocated on the managed heap. (The heap is the part of memory that is used to store objects, as opposed to the stack, which is used to store references to objects— more on heap and stack later.) The GC keeps track of the referenced objects on the heap and automatically frees up the memory allocated to a specific object when it goes out of scope. Calling the GC programmatically is possible by invoking the method System.GC.Collect. However, this is not recommended because it is not guaranteed that it will destroy your objects. It is best to focus on the business logic and let the CLR determine the right time for garbage collection.
Labels:
C#,
C++,
Free Quickbooks,
learn earn
Popular Posts
-
Samsung Galaxy Tab 10.1 WiFi Info Clip The official info clip for the Samsung Galaxy Tab 10.1 WiFi. The tab used in this video is 3G vers...
-
When you buy Visual Studio 2005, you get the full-featured integrated development environment (IDE). You can also get a free C# compiler by...
-
In addition to the title element, the head may also contain: base it defines base URLs for resources or links on the page, & target w...
-
Nokia N8 It's not technology; it's what you do with. Nokia N8 has the first 12 mega pixel camera with a Carl Zeiss lens and a bril...