591 cazuri COVID-19 în Moldova
557 – cazuri active
26 – cazuri vindecate
8 – cazuri fatale
Actualizarea datelor: 4 aprilie 2020 ora 07:54


Garbage collection

The garbage collector is .NET’s answer to memory management, and in particular to the question of what
to do about reclaiming memory that running applications ask for. Up until now there have been two
techniques used on the Windows platform for de-allocating memory that processes have dynamically
requested from the system:
❑ Make the application code do it all manually.
❑ Make objects maintain reference counts.
Having the application code responsible for de-allocating memory is the technique used by lower-level,
high-performance languages such as C++. It is efficient, and it has the advantage that (in general)
resources are never occupied for longer than unnecessary. The big disadvantage, however, is the frequency
of bugs. Code that requests memory also should explicitly inform the system when it no longer
requires that memory. However, it is easy to overlook this, resulting in memory leaks.
Although modern developer environments do provide tools to assist in detecting memory leaks, they
remain difficult bugs to track down, because they have no effect until so much memory has been leaked
that Windows refuses to grant any more to the process. By this point, the entire computer may have
appreciably slowed down due to the memory demands being made on it.
Maintaining reference counts is favored in COM. The idea is that each COM component maintains a
count of how many clients are currently maintaining references to it. When this count falls to zero, the
component can destroy itself and free up associated memory and resources. The problem with this is
that it still relies on the good behavior of clients to notify the component that they have finished with it.
It only takes one client not to do so, and the object sits in memory. In some ways, this is a potentially
more serious problem than a simple C++-style memory leak, because the COM object may exist in its
own process, which means that it will never be removed by the system (at least with C++ memory leaks,
the system can reclaim all memory when the process terminates).
The .NET runtime relies on the garbage collector instead. This is a program whose purpose is to clean up
memory. The idea is that all dynamically requested memory is allocated on the heap (that is true for all
languages, although in the case of .NET, the CLR maintains its own managed heap for .NET applications
to use). Every so often, when .NET detects that the managed heap for a given process is becoming full
and therefore needs tidying up, it calls the garbage collector. The garbage collector runs through variables
currently in scope in your code, examining references to objects stored on the heap to identify
which ones are accessible from your code—that is to say which objects have references that refer to
them. Any objects that are not referred to are deemed to be no longer accessible from your code and can
therefore be removed. Java uses a similar system of garbage collection to this.
Garbage collection works in .NET because IL has been designed to facilitate the process. The principle
requires that you cannot get references to existing objects other than by copying existing references and
that IL is type safe. In this context, what we mean is that if any reference to an object exists, then there is
sufficient information in the reference to exactly determine the type of the object.
It would not be possible to use the garbage collection mechanism with a language such as unmanaged
C++, for example, because C++ allows pointers to be freely cast between types.

One important aspect of garbage collection is that it is not deterministic. In other words, you cannot
guarantee when the garbage collector will be called; it will be called when the CLR decides that it is
needed (unless you explicitly call the collector). Though it is also possible to override this process and
call up the garbage collector in your code.

Sursa
2007-07-14 20:03:00



Comenteaza





Ultimele 25 posturi adăugate

00:17:14Dar ce facem cu dragostea din departare pe timpul pandemiei? —» Curaj.TV | Media alternativă
23:03:29Nu pierde timpul —» Păreri despre cei ce ne inconjoară
19:42:10În atenția moldovenilor din Israel: Vizele de lucru B1 sunt prelungite automat —» Elena Robu
19:32:41Valeriu Paşa despre repatrierea moldovenilor —» Curaj.TV | Media alternativă
14:46:32Vocea Diasporei, despre polița de asigurare care trebuie cumpărată de toți cei care revin acasă în această perioadă —» Elena Robu
14:23:57Ministerul Educației, Culturii și Cercetării anunță reluarea procesului educațional la distanță —» Liceul Teoretic “Mihail Sadoveanu”, Călăraşi
13:55:10MAIB a lansat serviciul de schimb valutar în numerar încă la 10 bancomate. Vezi unde le găsești! —» edufin.md
13:39:38«Самое время для новой жизни» Джонатан Троппер —» Блог Ирэн – Рецензии книг
13:34:05eBook Cartier. Top descărcări martie 2020 —» Gheorghe Erizanu
12:34:26Protest Online contra Chicu și Dodon —» Curaj.TV | Media alternativă
12:19:25O pensionară revoltată se adresează lui Dodon —» Curaj.TV | Media alternativă
10:16:58Apel public: Lucrătorii medicali trebuie protejați la maximum în contextul pandemiei COVID-19 în R. Moldova —» Elena Robu
10:14:56Все зарегистрированные безработные РМ получат материальную помощь —» Заметки Начинающего Журналиста
10:11:12Молдавские бренды Primul Sens, #mdHOMEmd Miedor и OMP объединились для помощи врачам, таможенникам и пенсионерам. Присоединяйся и ты! —» Заметки Начинающего Журналиста
09:57:44VW Golf R 500hp+ Moldova —» Сажевые фильтры (DPF/ FAP). Чип тюнинг. Теория, практика.
08:34:50FOTO. Grupul de inițiativă AO ”Baștina Frăsinești” au confecționat și dpruit măști de protecție comunității —» BPR Ungheni's Blog
23:08:52Galerie Foto // Unghenenii demonstrează responsabilitate și s-au conformat recomandărilor autorităților —» Blogul lui Marin Bodrug
20:28:31unsingulCluj.ro – inițiativa care susține medicii în lupta contra Coronavirusului —» Andrei Albu - omul alb cu gînduri negre
20:28:31unsingurCluj.ro – inițiativa care susține medicii în lupta contra Coronavirusului —» Andrei Albu - omul alb cu gînduri negre
20:23:26Moldova va scăpa de COVIȚ!!1 Un popă, pe samaliotu lui Machedon, a binecuvântat Moldova cu Icoana „Kasperskaia”!!!1 —» un alt blog
19:42:57Poem de LETICIA GARRIGA* —» Andrei LANGA. Blogul personal
18:00:42Ion Ciocanu: 80 de ani de la naştere —» Curaj.TV | Media alternativă
15:37:45Европейский Союз поддержит Молдову в рамках своей глобальной реакции на вспышку коронавируса —» Заметки Начинающего Журналиста
15:30:17В Кишиневе завершены работы по обустройству первого Центра по проверке пациентов с подозрением на COVID-19 —» Заметки Начинающего Журналиста
15:23:19Micile bucurii ale lunii martie —» Sunt MAMĂ!