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


// See if tonsOfObjects[9000] is still alive



Download 21,46 Mb.
Pdf ko'rish
bet520/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   516   517   518   519   520   521   522   523   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// See if tonsOfObjects[9000] is still alive.

if (tonsOfObjects[9000] != null)

{

Console.WriteLine("Generation of tonsOfObjects[9000] is: {0}",



GC.GetGeneration(tonsOfObjects[9000]));

}

else



Console.WriteLine("tonsOfObjects[9000] is no longer alive.");

// Print out how many times a generation has been swept.

Console.WriteLine("\nGen 0 has been swept {0} times",

GC.CollectionCount(0));

Console.WriteLine("Gen 1 has been swept {0} times",

GC.CollectionCount(1));

Console.WriteLine("Gen 2 has been swept {0} times",

GC.CollectionCount(2));

Console.ReadLine();

}

Here, we have purposely created a very large array of object types (50,000 to be exact) for test-



ing purposes. As you can see from the output shown in Figure 8-6, even though this Main() method

only made one explicit request for a garbage collection (via the GC.Collect() method), the CLR per-

formed a number of them in the background.

Figure 8-6.

Interacting with the CLR garbage collector via System.GC

At this point in the chapter, I hope you feel more comfortable regarding the details of object

lifetime. The remainder of this chapter examines the garbage collection process a bit further by

addressing how you can build 



finalizable objects as well as disposable objects. Be very aware that the

following techniques will only be useful if you are building managed classes that maintain internal

unmanaged resources.


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   516   517   518   519   520   521   522   523   ...   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