Glossary of VM Terms
To truly understand how Observatory works, you need to understand computer science concepts such as memory allocation, the heap, garbage collection, and memory leaks. This glossary contains brief definitions of some of the terms used by Observatory.
Garbage collection (GC)
Garbage collection is the process of searching the heap to locate, and reclaim, regions of “dead” memory—memory that is no longer being used by an application. This process allows the memory to be re-used and minimizes the risk of an application running out of memory, causing it to crash.
Garbage collection is performed automatically by the Dart VM. In Observatory, you can perform garbage collection on demand by clicking the GC button in the Allocation Profile screen.
Dart objects that are dynamically allocated live in a portion of memory called the heap. An object allocated from the heap is freed (eligible for garbage collection) when nothing points to it, or when the application terminates. When nothing points to an object, it is considered to be dead. When an object is pointed to by another object, it is live.
See the dart reference page for information on how to increase the size of old generation.
Dart supports concurrent execution by way of isolates, which you can think of as processes without the overhead. Each isolate has its own memory and code, which can’t be affected by any other isolate. For more information, see The Event Loop and Dart.
Each Dart app contains at least one isolate, named root. When you launch Observatory, the VM screen lists all isolates for the application. You can browse and interact with each isolate, separately, by clicking that isolate’s name.
Memory fragmentation occurs when free memory is splintered into small blocks that are scattered throughout allocated memory. This phenomenon can negatively affect an application’s performance and can lead to an out of memory exception.
You can find memory fragmentation using Observatory’s Heap map. This feature displays an image where free space is indicated by white blocks. Many small white areas sprinkled throughout the colored areas suggest that the application is experiencing memory fragmentation. For more information, see Heap Map.
A memory leak occurs when an object is live (meaning that another object points to it) but it is not being used (so it shouldn’t have any references from other objects). Such an object can’t be garbage collected, so it takes up space in the heap and contributes to memory fragmentation. Memory leaks put unnecessary pressure on the VM and can be difficult to debug.
Most newly created objects (unless they are very large) are allocated in a part of the heap named new generation. New generation is particularly suited for objects that are temporary and short lived—it is small and is designed to be garbage collected quickly.
When an object has been around awhile and has survived a garbage collection cycle, it is typically promoted to a part of the heap named old generation, freeing up new generation for newly created objects.
The heap map feature of Observatory gives you a way to visually browse old generation. For more information, see Heap Map.
Virtual machine (VM)