How do the logic differ among:
- C++ DLL
- C# DLL
- EX5
Any type of DLL code is shared, and the memory usage, can be shared, global or local depending on how the DLL is implemented and coded.
EX5 memory usage is local to each running instance. There is no IPC. To share variables between instances, you have to use the Terminal Global Variables.
bot:
I have done some tests and it seems that same MQL5 string when passed to a C# DLL it is copied each time, rather than passing by references.
Since both MQL5 and C# have the same struct to represent the strings, in order to have good performance, can the MT Dev team please change it to pass by reference, very similar to what can be done to C++ DLLs?
I have deleted your new topic and pasted it above.
You are starting multiple topics that are related. If you want to discuss DLLs, keep it all in one topic.
I have deleted your new topic and pasted it above.
You are starting multiple topics that are related. If you want to discuss DLLs, keep it all in one topic.
That issue is not related to this thread's title "Sharing C++ DLL, C# DLL and EX5 among multiple EA/Service", but related to string performance bottleneck when MQL5 using C# DLL.
Ideally this string performance bottleneck should be reported to the Dev for them to look into in near future.That issue is not related to this thread's title "Sharing C++ DLL, C# DLL and EX5 among multiple EA/Service", but related to string performance bottleneck when MQL5 using C# DLL.
Ideally this string performance bottleneck should be reported to the Dev for them to look into in near future.How are you passing the string from MQL5 to C#?
just calling the method like:
string str = "MQL5"; sample01::Class01::SayGreeting(str); sample01::Class01::SayGreeting(str); sample01::Class01::SayGreeting(str);
in each call a new copy of the str given to the C# method. str should be passed as a reference to C# instead. or atleast the underlying uchar[] address should be passed as the same address.
Above is just a sample code to demo the issue.just calling the method like:
in each call a new copy of the str given to the C# method. str should be passed as a reference to C# instead. or atleast the underlying uchar[] address should be passed as the same address.
Above is just a sample code to demo the issue.What's the signature of SayGreeting?
Tried both, still the strings are getting copied each time.
public static string SayGreeting(string name)
public static string SayGreeting(ref string name)
Note, I can get references passed for arrays of int, double etc, but not string. string is very critical to have good performance as it is always needed.
A question I have is, is it possible to get the ushort[] array for the MQL5 string?
Tried both, still the strings are getting copied each time.
Note, I can get references passed for arrays of int, double etc, but not string. string is very critical to have good performance as it is always needed.
A question I have is, is it possible to get the ushort[] array for the MQL5 string?
Please read the mql documentation before flooding the forum with trivial questions. Thank you.
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2022.02.09 16:42
Why don't you just try it for yourself and see? One learns best by "doing"!
Also, there is something called "documentation" and it is quite extensive and available Online and Offline both in CHM and PDF formats.
There are also numerous Articles as well examples of code in the CodeBase on various things! Run a Search and see what you can find.
Please read the mql documentation before flooding the forum with trivial questions. Thank you.
@Alain Verleyen I am aware of StringToCharArray "Symbol-wise copies a string converted from Unicode to ANSI", but it copies data to a new uchar[], rather than provides references to underlying ushort[]
My question is related to the overhead in doing so.
Anyway, my original query is still valid as to why same string variable passed to C# DLL getting copied each time and whether there is a way to pass as references instead.
@Alain Verleyen I am aware of StringToCharArray "Symbol-wise copies a string converted from Unicode to ANSI", but it copies data to a new uchar[], rather than provides references to underlying ushort[]
My question is related to the overhead in doing so.
Anyway, my original query is still valid as to why same string variable passed to C# DLL getting copied each time and whether there is a way to pass as references instead.
What "underlying ushort" ? You are working with a string if you want it in ushort you need to converted it (copy). You can use StringToShortArray() for that.
Use supported .NET version and you will avoid a lot of trouble. You should never rely on Metaquotes as you never know if and when they will add/fix what you want.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
If multiple EAs/Services load the same library (lets call Lib1), will there be one or multiple instances of Lib1 running and will any in memory global variables be shared or isolated?
How do the logic differ among: