C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet813/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   809   810   811   812   813   814   815   816   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

AddMemoryPressure( )

 and 


RemoveMemoryPressure( )

. These are used to 

indicate that a large amount of unmanaged memory has been allocated or released by the 

program. They are important because the memory management system has no oversight 

on unmanaged memory. If a program allocates a large amount of unmanaged memory, then 

performance might be affected because the system has no way of knowing that free memory 

has been reduced. By calling 

AddMemoryPressure( )

 when allocating large amounts of 

unmanaged memory, you let the CLR know that memory has been reduced. By calling 

RemoveMemoryPressure( )

, you let the CLR know the memory has been freed. Remember: 



RemoveMemoryPressure( )

 must be called only to indicate that memory reported by a call 

to

AddMemoryPressure( )

 has been released.

Method

Meaning


public static void

    AddMemor yPressure(long 



size

)

Indicates that 



size

 number of bytes of unmanaged 

memor y have been allocated. 

public static void Collect( )

Initiates garbage collection.

public static void Collect(int 



maxGen

)

Initiates garbage collection for memor y with generation 



numbers of 0 through 

maxGen.

public static void Collect(int 



maxGen

,

                  GCCollectionMode 



GCMode

)

Initiates garbage collection for memor y with generation 



numbers of 0 through 

maxGen

 as specified by 



GCMode

.

public static int CollectionCount(int 



gen

)

Returns the number of garbage collections that have 



taken place for memor y having the generation number 

specified by 



gen.

public static int GetGeneration(object 



o

)

Returns the generation number for the memor y referred 



to by 

o.

public static int

    GetGeneration(WeakReference 

o

)

Returns the generation number for the memor y 



referred to by the weak reference specified by 

o.

 A 


weak reference does not prevent the object from being 

garbage-collected.

public static long

    GetTotalMemor y(bool 



collect

)

Returns the total number of bytes currently allocated. If 



collect

 is true, garbage collection occurs first. 

public static void KeepAlive(object 

o

)

Creates a reference to 



o,

 thus preventing it from being 

garbage collected. This reference ends when 

KeepAlive( )

executes.

public static void

    RemoveMemor yPressure(long 

size

)

Indicates that 



size

 number of bytes of unmanaged 

memor y have been released. 

public static void

    ReRegisterForFinalize(object 

o

)

Causes the finalizer (i.e., the destructor) for 



o

 to be called. 

This method undoes the effects of 

SuppressFinalize( )

.

public static void



    SuppressFinalize(object 

o

)

Prevents the finalizer (i.e., the destructor) for 



o

 from 


being called. 

public static void

    WaitForPendingFinalizers( )

Halts execution of the invoking thread until all pending 

finalizers (i.e., destructors) have been called.

T

ABLE



 21-15 

Methods Defi ned by 

GC

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   809   810   811   812   813   814   815   816   ...   1096




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