Interpreting the Memory Monitor display
A Memory Monitor can help you estimate the amount of memory it takes to run code. You use it to see whether your code hogs memory or is running efficiently. When interpreting a Memory Monitor's display, you look at the following information:
The number of bytes allocated for each memory segment
The extent to which objects remain in use
The frequency of scavenges
The number of bytes allocated for a memory segment within a certain time period is shown along the bottom of the Memory Monitor window. Programs that require the system to allocate a large number of bytes quickly use more memory than do programs that require fewer bytes allocated.
The extent to which objects remain in use is ascertainable by deducting the number of bytes allocated at the start of a segment from the number allocated at the end of the previous segment. Or you can estimate the extent to which objects remain in use by seeing how high a new segment begins. Segments that begin at the bottom of the graph have few (or no) objects that remain in use. Segments that begin higher up have more persistent objects. Programs that have a high degree of objects that remain in use take up more memory than do those which lose their objects during scavenges.
The frequency of scavenges is shown by the pitch and number of up-and-down lines in the graph. For the default monitoring of one-second intervals with samples taken every ten milliseconds, graphs that show frequent scavenges denote a large use of memory.
For example, suppose you press Start, and then print file names to the Transcript by evaluating the following:
| dir filename |
dir := CfsDirectoryDescriptor opendir: '.'
pattern: '*' mode: FREG | FDIR | FSPECIAL.
[(filename := dir readdirName) == nil]
whileFalse: [Transcript cr; show: filename].
dir closedir
The Memory Monitor displays information resembling the following for new space allocations:
Memory Monitor
This shows that running the code (the middle two peaks) left objects in use and required more frequent scavenges. However, because the peaks are not markedly different from those for when the code is not being run, the graph does not suggest that running the code used much memory.
The sample rate indicates how often the memory space is monitored and its current level updated. New space should be monitored frequently (around 10-25 ms) since it is constantly changing. Old or fixed space can be monitored much less often (250-750 ms is a good starting value, but the value depends on how many objects are tenured).
Tips
Multiple memory monitors can be started and changed to monitor different memory spaces by choosing the appropriate space in the dialog that opens after you select Memory Segment from the Monitor menu.
 
Last modified date: 03/12/2020