Controlling Garbage Collection
For most applications, interacting with the garbage collector will not be necessary. However, there may be times when it's desirable to invoke a garbage collection or inspect the status of some objects. For example, during program idle time or during an I/O might be good opportunities to force a garbage collection. This may minimize the possibility of a garbage collection during times when the program needs CPU cycles for higher priority tasks.
Controlling Objects
The GC class has several class members for working with the garbage collector; these are shown in Table 34.1. For an example of how to force a garbage collection and observe its effects, see Listing 34.3.
Member Name | Description ... |
---|
Get C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.