Using Memory Tagging
The sequential development kernel tags allocated memory at creation time based on what allocated that memory. This feature is designed to help you track memory leaks. The Simulation Kernel tags all packet-related memory at the time of allocation and when the corresponding packet changes owner. Thus, you can see where the packet was created or who last owned the packet. ODB uses the commands listed in Table 20 to support memory tagging.
Table 20: Memory Tagging Commands
| Command | Description |
|---|---|
| "mtagfilter" | Sets or changes the filter for memory tagging. |
| "mtagflush" | Flushes memory tags. |
| "mtagoff" | Disables memory tagging. |
| "mtagon" | Enables memory tagging. |
| "mtagprint" | Prints information about tagged memory category objects. |
The following steps represent a typical workflow for using memory tagging to debug memory leaks.
-
Identify that a memory leak occurs via the Memory Stats tabbed page of the Simulation Progress dialog box.
- Watch the memory usage graph for an increasing memory usage pattern that does not decrease. You may have to observe the graph for an extended period of simulation time to spot an increasing long-term trend that is beyond the short-term fluctuations.
- Use the "delta" feature to identify particular memory categories that increase.
-
Restart the simulation with ODB enabled. Be sure to use a development kernel.
-
Enable memory tagging for the problematic memory categories (using
mtagon "category 1" "category 2"). Do this at an appropriate simulation time (time 0 is typical).If you cannot limit your investigation to specific memory categories, start by enabling memory tagging for all categories (
mtagon all). -
Let the simulation run until enough events have been generated for the leak to appear.
-
Use
mtagprintto investigate currently active memory. You must determine whether active memory objects are indeed "leaks" or simply normal memory usage.- Identify the memory categories that are leaking (
mtagprint C). The displayed categories should match the categories filtered (or should corroborate categories identified in step 1, if you used theallfilter). - Identify the node, process, simulation time, and so on that is the main culprit of leaks using
mtagprintand an appropriate limit. (The limit prevents output of all tagged memory objects.)
- Identify the memory categories that are leaking (
-
Debug the problem.