Tracking Memory Usage
Occasionally, a simulation will contain memory leaks due to missing deallocations or incorrect logic. To help you solve these problems, Modeler provides a variety of tools for tracking memory usage. These tools help you to identify what type of memory is leaking and the allocation sources of the leaking memory.
A lot of information about memory usage is available in the GUI while running a simulation. Some of this information is available by default and some (because of its impact on simulation performance) must be deliberately enabled before running the simulation.
You can specify which memory usage displays you want to see from the Runtime Displays > Memory Usage page of the “Configure/Run DES Dialog Box (Detailed)”. This page controls three types of memory usage information that you can view in the Simulation Progress dialog box as the simulation runs.
- “Graph total memory usage during simulation” checkbox (enabled by default) – This graph appears on the “Memory Usage Page” of the Simulation Progress dialog box. An increasing trend in this graph (aside from expected memory allocations early in the simulation) can indicate the presence of a memory leak.
- “Show memory statistics panel” checkbox (enabled by default) – This information appears on the “Memory Stats Page” of the Simulation Progress dialog box. It contains details about each particular memory category used in the simulation. To update the Memory Stats page automatically, enable the “Data is generated when generating progress reports” and “Generate final usage data once simulation ends” checkboxes.
A good approach for memory statistics is to sort by the “Use (KB)” column, which makes it easy to see which categories are consuming the most memory. If one of these categories is “Packet” or packet-related, you might need to check for one of these situations:
- more packets are being generated than the system can handle
- packets are not being destroyed properly at their destination (a leak)
- “Generate memory source tracing information” checkbox – This information appears on the “Memory Sources Page” of the Simulation Progress dialog box. This feature is useful if the memory statistics point to a broad memory category (such as Packet or op_prg memory) and you need to see where and when the problematic memory was allocated. You can sort the memory sources display by the amount of memory allocated and follow a function call stack that shows exactly where the memory was allocated. Also, you can right-click on a function to view the individual blocks that have been allocated and watch them disappear as they are freed. For details, see “Using Memory Source Tracing” on page 57.
Additional methods for tracking memory usage are available when using the Simulation Debugger. These methods provide similar types of information to that available from the GUI, but within the context of ODB. For information about these methods, refer to the following topics:
- “Memory Allocator Commands” – ODB commands for displaying memory statistics and information about allocation sources and deallocation sinks
- “Using Memory Tagging” – ODB commands for tracking packet-related memory through a simulation
You can also track memory usage by placing a Memory Usage node in your network model. This utility object prints memory usage statistics at specified intervals during simulation execution or when requested. The printed results are similar to those produced by the ODB “memstats” command.