I'm using the Include File shown above only during the development and testing stage of a new EA. I want to ensure, that I do not have any memory leaks.
Later during life operation I simply do not include the file.
In contribution #6 of this thread I presented my version of an include file for checking and identifying memory leaks. Let us name this file "check_for_memory_leaks.mqh".
The following little script with name "little_script.mq5" uses this header file:
#include "check_for_memory_leaks.mqh"class CA {
};
voidOnStart() {
CA *a;
a = new CA;
if (a == NULL) {
Print("NULL Pointer!");
return;
}
delete a;
}
Now I want to preprocess the source code by the following command:
In contribution #6 of this thread I presented my version of an include file for checking and identifying memory leaks. Let us name this file "check_for_memory_leaks.mqh".
The following little script with name "little_script.mq5" uses this header file:
Now I want to preprocess the source code by the following command:
cpp little_script.mq5 -E
The output is
Please see the two bold marked lines
This is for clarity.
Matthias
PS: cpp is part of the GNU compiler collection of cygwin
Nice displaying.
I was thinking to integrate a object search function for manual identification....
Also, I think it could be interesting to print out IDs for all objects that have not been deleted as a CSV line in the journal.
Then this line could be used as input to the mem leak finder to make it "DebugBreak" when this specific ID is being created, in a second run. - I think it could make debugging much easier, because the debugger would halt when this object is created and the surrounding circumstances could be analyzed.
I hope my explanation was understandable.
BTW, how did you make GCC interpret a .mq5 file as a c/c++ file? I haven't been able to make use of the preprocessor like you did. I tried with clang and GCC...
BTW, how did you make GCC interpret a .mq5 file as a c/c++ file? I haven't been able to make use of the preprocessor like you did. I tried with clang and GCC...
Neither gcc nor g++ work with extension .mq5; but cpp does! God knows why
Neither gcc nor g++ work with extension .mq5; but cpp does! God knows why
Its CPP... Oh, thank you for sharing.
You like that macro magic trick to substitute/inject code into given source files, don't you. But you are also already seeing the dangers/issues/hidden errors it can bring.
I had spent hours debugging code with a hidden and unconscious substitution to find a typo...
You like that macro magic trick to substitute/inject code into given source files, don't you. But you are also already seeing the dangers/issues/hidden errors it can bring.
I had spent hours debugging code with a hidden and unconscious substitution to find a typo...
Thank for the tip. Yes I know about the dangers/issues you mentioned. That is why I use macros very seldom and preferentially only during the development and testing stage of a project.
And I'm using the statement "cpp <file> -E" for preprocessing the source code in order to see the real code.
I try to avoid these techniques during the life stage with real money...
Matthias
BTW: In the header file " check_for_memory_leaks.mqh" I removed/outcommented the first line "#include <Generic/HashMap>" before calling cpp...
Thank for the tip. Yes I know about the dangers/issues you mentioned. That is why I use macros very seldom and preferentially only during the development and testing stage of a project.
And I'm using the statement "cpp <file> -E" for preprocessing the source code in order to see the real code.
I try to avoid these techniques during the life stage with real money...
Matthias
BTW: In the header file " check_for_memory_leaks.mqh" I removed/outcommented the first line "#include <Generic/HashMap>" before calling cpp...
Yes. - Do you want to publish this in Code-Base maybe?? For me this is fine, you may go ahead, if you wish to do so.... - Maybe you would claim GPLv2 license on it. Thats what I do with my published code.
Dominik Egert #: Yes. - Do you want to publish this in Code-Base maybe?? For me this is fine, you may go ahead, if you wish to do so.... - Maybe you would claim GPLv2 license on it. Thats what I do with my published code.
Dominik Egert #: Yes. - Do you want to publish this in Code-Base maybe?? For me this is fine, you may go ahead, if you wish to do so.... - Maybe you would claim GPLv2 license on it. Thats what I do with my published code.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi,
I'm using the Include File shown above only during the development and testing stage of a new EA. I want to ensure, that I do not have any memory leaks.
Later during life operation I simply do not include the file.
Matthias
Hi,
just for clarity and better understanding.
In contribution #6 of this thread I presented my version of an include file for checking and identifying memory leaks. Let us name this file "check_for_memory_leaks.mqh".
The following little script with name "little_script.mq5" uses this header file:
Now I want to preprocess the source code by the following command:
cpp little_script.mq5 -E
The output is
Please see the two bold marked lines
This is for clarity.
Matthias
PS: cpp is part of the GNU compiler collection of cygwin
Hi,
just for clarity and better understanding.
In contribution #6 of this thread I presented my version of an include file for checking and identifying memory leaks. Let us name this file "check_for_memory_leaks.mqh".
The following little script with name "little_script.mq5" uses this header file:
Now I want to preprocess the source code by the following command:
cpp little_script.mq5 -E
The output is
Please see the two bold marked lines
This is for clarity.
Matthias
PS: cpp is part of the GNU compiler collection of cygwin
Neither gcc nor g++ work with extension .mq5; but cpp does! God knows why
Neither gcc nor g++ work with extension .mq5; but cpp does! God knows why
Thank for the tip. Yes I know about the dangers/issues you mentioned. That is why I use macros very seldom and preferentially only during the development and testing stage of a project.
And I'm using the statement "cpp <file> -E" for preprocessing the source code in order to see the real code.
I try to avoid these techniques during the life stage with real money...
Matthias
BTW: In the header file " check_for_memory_leaks.mqh" I removed/outcommented the first line "#include <Generic/HashMap>" before calling cpp...
Thank for the tip. Yes I know about the dangers/issues you mentioned. That is why I use macros very seldom and preferentially only during the development and testing stage of a project.
And I'm using the statement "cpp <file> -E" for preprocessing the source code in order to see the real code.
I try to avoid these techniques during the life stage with real money...
Matthias
BTW: In the header file " check_for_memory_leaks.mqh" I removed/outcommented the first line "#include <Generic/HashMap>" before calling cpp...
Yes. - Do you want to publish this in Code-Base maybe?? For me this is fine, you may go ahead, if you wish to do so.... - Maybe you would claim GPLv2 license on it. Thats what I do with my published code.
I think about it.
Yes. - Do you want to publish this in Code-Base maybe?? For me this is fine, you may go ahead, if you wish to do so.... - Maybe you would claim GPLv2 license on it. Thats what I do with my published code.
Please see https://www.mql5.com/en/code/45873
This is my first publication, may be clumsy
Please see https://www.mql5.com/en/code/45873
This is my first publication, may be clumsy