This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy



Download 21,46 Mb.
Pdf ko'rish
bet527/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   523   524   525   526   527   528   529   530   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition



Source Code

The SimpleFinalize project is included under the Chapter 8 subdirectory.



Detailing the Finalization Process

Not to beat a dead horse, but always remember that the role of the Finalize() method is to ensure

that a .NET object can clean up unmanaged resources when garbage collected. Thus, if you are

building a type that does not make use of unmanaged entities (by far the most common case), final-

ization is of little use. In fact, if at all possible, you should design your types to avoid supporting a

Finalize() method for the very simple reason that finalization takes time.

When you allocate an object onto the managed heap, the runtime automatically determines

whether your object supports a custom Finalize() method. If so, the object is marked as



finalizable, and a pointer to this object is stored on an internal queue named the finalization queue.

The finalization queue is a table maintained by the garbage collector that points to each and every

object that must be finalized before it is removed from the heap.

When the garbage collector determines it is time to free an object from memory, it examines

each entry on the finalization queue and copies the object off the heap to yet another managed

structure termed the 



finalization reachable table (often abbreviated as freachable, and pronounced

“eff-reachable”). At this point, a separate thread is spawned to invoke the Finalize() method for

each object on the freachable table 

at the next garbage collection. Given this, it will take at the very

least two garbage collections to truly finalize an object.

The bottom line is that while finalization of an object does ensure an object can clean up

unmanaged resources, it is still nondeterministic in nature, and due to the extra behind-the-

curtains processing, considerably slower.

C H A P T E R   8  




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   523   524   525   526   527   528   529   530   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish