2. Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
6. • The Microsoft .NET common language
runtime requires that all resources be
allocated from the managed heap. Objects are
automatically freed when they are no longer
needed by the application.
7. • When a process is initialized, the runtime
reserves a contiguous region of address space
that initially has no storage allocated for it.
This address space region is the managed
heap. The heap also maintains a pointer. This
pointer indicates where the next object is to
be allocated within the heap. Initially, the
pointer is set to the base address of the
reserved address space region.
8. Garbage Collection
• In C#, the deallocation or freeing of resources
consumed by created instances occurs
automatically on a system-determined
schedule by an intelligent mechanism known
as garbage collection.
9. • The GC in C# improves on the concept
because it does not reduce the system's
performance until really needed. It is smarter
than other garbage collectors currently on the
market. You can overcome the disadvantages
of CG's nondeterministic behavior by using
destructors (dtors) and finalizers. You can
allocate member instances with constructors
(ctors). Let's explore some important aspects
of garbage collecting in .NET.
10. • class X
{
// implicit dtor ~X()
// created for you automatically by C#
}
class Y
{
~Y() // explicit dtor, same as Finalize
{
// some code
}
}
//verbose syntax:
class Z
{
protected override void Finalize() //verbose explicit dtor, same as ~
{
// Some code
// implicit call to base.Finalize();
}
}
11. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
12. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com