Ive been using mysql for working with my EAs for some time now, I used mainly this EAX Library https://www.mql5.com/en/code/855, which I added a couple of functions and some error handlers for reconnections in case the connection gets dropped while executing a query, everything works perfectly except for one scenario when I load a lot of experts (9 at this point) on a single terminal all using this type of connection, when I restart my computer and load the terminal I would often get Access violation at 0x000000007788E4E4 write to 0x0000000000000024 and that expert will freeze there, If i close the terminal and open it back again without restarting the computer it will load without any problems, after a long research and debugging on my EAs Ive found out that this access violation will happen when the EA is trying to allocate the memory for the mysql object using the function mysql_init(), I was wondering if anyone can shed some light over here, if theres a way for me to ignore the exception and let the expert continue or if theres a workaround. Here is a little resumed code that will cause the error, am working on Windows 7 Ultimate x6, MySQL DataBase 5.1.73, libmysql 6.1.2.
input string MYSQLSTR="++++ MYSQL CONNECTION PARAMETERS ++++";
input string MySqlHost="localhost"; //MySql Host:
input string MySqlUser="user"; //MySQL User:
input string MySqlPass="1234"; //MySQL Password:
input string MySqlDB="sqltest"; //MySQL Table:
input int MySqlPort=3306; //MySQL Port:
//--- FUNCION DE INICIALIZACION
//--- FUNCION DE DESINICIALIZACION
void OnDeinit(const int reason)
//--- MODULO DE SENALES
//--- FUNCION DE EJECUCION POR TICKS
EAX_Mysql *db=new EAX_Mysql();
StringConcatenate(query,"SELECT CF_UpdateNumber FROM config WHERE CF_Key = '0'","");
for(int i=0; i<iResults; i++)
Print("GetTimeFrame = ", portfolioidrs);
Sounds as if you know what the problem is but don't know where to start..
Ive found out that this access violation will happen when the EA is
trying to allocate the memory for the mysql object using the function
Have you solved this issue? I am also experiencing issues with memory allocation. I'm also using windows 7 though I have the most recent .dd release (126.96.36.199)
hey i've been experiencing this issue myself, once mt5 is loaded it works just fine but am getting some weird memory errors they look like memory addresses to me but am no expert programer, were you able to find a solution? please share thanks!
I've been having those Access Violation errors too, and I figured out how to fix them.
It happens that in many places, the type int is used to hold the value of what is actually a pointer to some structure or object belonging to the MySQL lib and that is not interpreted by MQL5, so you just store it as int for reference. However, the type int is 32-bits regardless of your architecture, and if you are using 64-bit system, the type int is not big enough to contain the value of a pointer. You have to use long instead.
Most libmysql.dll functions return pointers, such as mysql_init(), mysql_real_connect(), mysql_real_query(), etc, and most MQL5 scripts store the return value of those functions as int, an insufficient data type to represent those pointers, which is causing those problems.
I managed to get my scripts working perfectly in 64-bit environment by using long instead of int in some strategic places. Since all I really need is to insert stuff in the database, I only needed to change the functions I mentioned above.