Information Technology Reference
In-Depth Information
to other entities. Just like the relational database entity sets model, these
links and references may be circular.
There are references all through the web of objects represented by differ-
ent EntitySets. Releasing memory is the GC's responsibility. Because the
.NET Framework designers did not need to free these objects, the com-
plicated web of object references did not pose a problem. No decision
needed to be made regarding the proper sequence of freeing this web of
objects; it's the GC's job. The GC's design simplifies the problem of iden-
tifying this kind of web of objects as garbage. The application can stop ref-
erencing any entity when it's done. The Garbage Collector will know if the
entity is still reachable from live objects in the application. Any objects
that cannot be reached from the application are all garbage.
The Garbage Collector runs in its own thread to remove unused memory
from your program. It also compacts the managed heap each time it runs.
Compacting the heap moves each live object in the managed heap so that
the free space is located in one contiguous block of memory. Figure 2.1
shows two snapshots of the heap before and after a garbage collection. All
free memory is placed in one contiguous block after each GC operation.
As you've just learned, memory management (for the managed heap) is
completely the responsibility of the Garbage Collector. Other system
Letters in parentheses indicate owned references.
Hashed objects are visible from application.
F
E (F)
(B, D) has been removed from memory.
Heap has been compacted.
D
F
C
E (F)
B
C
Main Form
(C, E)
Main Form
(C, E)
Figure 2.1 The Garbage Collector not only removes unused memory, but it also
moves other objects in memory to compact used memory and maximize
free space.
 
Search WWH ::




Custom Search