Verifying Action Cleanness
This page demonstrates how action cleanness can be verified using the Heap Profiler. By cleanness, we mean that after starting and completing (or canceling) the action, no garbage is left. If an action leaves garbage, multiple invocations of it may result in excessive memory usage.
Below is the source code of the script, for reference:
- Take a heap snapshot
- Press the button:
- Take another snapshot
- Open the Comparison view
The view will show how objects count has changed between two
snapshots. In this example it can be seen that some
Item objects are left from the last loop
iteration. They must be explicitly dereferenced on action completion
in order to fix the leak.
You can also take multiple snapshots, and compare them arbitrarily (not necessary to complete the last one with the previous one.)