Xojo Instruments is a runtime tool to diagnose memory leaks and circular references in Xojo Desktop applications.
XojoInstruments_0.3.0_Demo.mov
- Download the latest release from Releases.
- Open Xojo Instruments project in Xojo IDE in
DesktopAppfolder. - Copy
XojoInstrumentsfolder to your project using the IDE. - Insert the following line to the top of
App.Open(orApp.Opening) event handler of your project.
XojoInstruments.Start()
Hint: If you are using Xojo 2021 Release 3 or later, you may need to change the Super of XojoInstrumentsDesktopGUI to DesktopWindow.
- Run your application.
- Click
CaptureinXojo Instrumentswindow to capture the current runtime status. - Do something in your application.
- Click
Capture & Compare. - Go to
Comparisontab to see what objects has been added/removed.
While running your application under the IDE, you can also view the selected object in IDE by clicking Inspect in IDE.
Reference Graph represents a dependency (reference hierarchy) between objects. You can possibly find circular reference by using the graph.
- Turn on
Build Reference Graphand clickCapture. - Go to
Visualizationtab. - (Optional) Turn on
Detect circularto automatically highlight circular references in the graph. - Click
Render.
While running your application under the IDE, you can view the object in IDE by double-clicking a object node in the graph.
You can choose either vis.js (bundled with Xojo Instruments, not supported on Windows) or dot command (GraphViz - needs to be installed separately) to render the graph.
You can also use Backreference tab to see back reference (list of objects referring the target object).
- As Xojo framework itself creates/caches some instances, you may notice unexpected "leaks" of instances.
Common ones are
EndOfLine,DockItemandXojo.Introspection.*. - Reference graphs are built by traversing properties of each object.
Please be aware that due to the limitation of introspection mechanism, Xojo Instruments cannot capture all references.
Here is an example of references that cannot be captured:
- Delegates (e.g., reference created by
AddHandler/AddressOf) - Module properties
- Shared class properties
- Static variables
- Reference between window and non-control instances / container controls
- Some objects used by Xojo framework itself
- Delegates (e.g., reference created by
- When comparing any two snapshots, you will at least see 1 added & 1 removed
Delegateinstance. This is a known limitation.
MIT License