Detecting MQL5 Memory Leaks During Strategy Tester Runs
Summary
The document explains how to use an MQL5 include file to identify objects allocated with the new operator but left undeleted in expert advisors, scripts, or custom indicators. The header is placed at the start of a program and instruments allocation and deallocation so that the strategy tester can report outstanding objects and their allocation locations. The article frames this as a way to catch software defects while testing trading applications.
A small script deliberately omits deletion of an allocated object. Its sample tester output reports one undeleted object and identifies the source file and line where it was allocated, illustrating how the report can guide debugging. The method is a development aid rather than a trading strategy or a complete memory-safety guarantee; the document does not discuss its technical limitations or test coverage. It recommends removing the diagnostic include after testing and correcting detected leaks.
Key ideas
- MQL5 programs can leak memory when dynamically allocated objects are not deleted.
- The proposed include file instruments allocation and deallocation during strategy tester runs.
- The example output identifies the number of leftover objects and their allocation locations.
- The tool is intended to help debug expert advisors, scripts, and custom indicators.
- The document does not establish that the checker detects every possible memory issue.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.