Reduce Ram Memory

 

Hi,


 I Have a EA that consumes 2GB of ram memory, this is a huge EA, it starts to consume this amount just when I start it and even not starting, I mean, on OnInit it starts to consume this Ram memory, is it possible reduce the consume?

Thanks

 
Of course it's possible, just use less memory.
 
Eric Sebestyen Ferreira: OnInit it starts to consume this Ram memory, is it possible reduce the consume?

Fix your broken code.

 
William Roeder #:

Fix your broken code.

Kkkkkkkk I think that you did not read what I wrote. The Metatrader starts do consume 2gb ram before execute my code, if I stop to debug on the first line of Oninit event it does consume 2gb. So my code is not executed yet in this moment.
 
Eric Sebestyen Ferreira #:
Kkkkkkkk I think that you did not read what I wrote. The Metatrader starts do consume 2gb ram before execute my code, if I stop to debug on the first line of Oninit event it does consume 2gb. So my code is not executed yet in this moment.
It's is your code of course, they are global initializations ran before OnInit.
 
Ok thank you, so if this occurs before OnIn how can I see what is causing this amount of ram memory. The EA has only 5.5 mb how can cause a 2gb of ram memory consume?
 
Eric Sebestyen Ferreira #: Ok thank you, so if this occurs before OnIn how can I see what is causing this amount of ram memory. The EA has only 5.5 mb how can cause a 2gb of ram memory consume?

My most complex EA only has 236KB. 5.5MB is HUGE!

 

Yes but mine is really  really  HUGE, I believe that RaZop project is the hughesnet created in MQL5.

Any way Alain helps a lot, and I found the problem, it is related to  global initializations, then I fund in here that the global initializations create first the statics and dynamics variables.

The thing is that I use a matrix M[400][40][300] size because I am not able to resize second and the third dimension, I am only able to change the first dimension, then I declared a static matrix with all possibilites. 

If there is a way to resize the second and the third dimension it will save me.  I only found this https://www.mql5.com/en/forum/315929

But if anybody know another way I will be glad.

How to resize 2d array?
How to resize 2d array?
  • 2019.06.17
  • www.mql5.com
Hello. I'm trying to resize 2d array.Could anybody help me? I'm trying it in MQL4...
 
Eric Sebestyen Ferreira #:

Yes but mine is really  really  HUGE, I believe that RaZop project is the hughesnet created in MQL5.

Any way Alain helps a lot, and I found the problem, it is related to  global initializations, then I fund in here that the global initializations create first the statics and dynamics variables.

The thing is that I use a matrix M[400][40][300] size because I am not able to resize second and the third dimension, I am only able to change the first dimension, then I declared a static matrix with all possibilites. 

If there is a way to resize the second and the third dimension it will save me.  I only found this https://www.mql5.com/en/forum/315929

But if anybody know another way I will be glad.

Its not a question of resizing a 2nd or 3rd dimension. It is a question of proper design and implementation of using array of structures dynamically allocated and/or classes.

Its your code design that is the cause of the problem.

I recently also needed to make use of 3 dimensional data that needed to be dynamically sized as needed. You just need to properly analyse the requirements and properly implement the solution so that it is efficient.

EDIT: I can't exactly explain the solution, because each case is different and needs a different approach accordingly.

 
Fernando Carreiro #:

Its not a question of resizing a 2nd or 3rd dimension. It is a question of proper design and implementation of using array of structures dynamically allocated and/or classes.

Its your code design that is the cause of the problem.

I recently also needed to make use of 3 dimensional data that needed to be dynamically sized as needed. You just need to properly analyse the requirements and properly implement the solution so that it is efficient.

EDIT: I can't exactly explain the solution, because each case is different and needs a different approach accordingly.

So what would you recommend Inbmy problem? I have  up to 400 symbols each one has up 40 months and each month I have up 300 options symbols with up to 30 parameters each, like (expire date, strike, price, volumes...). The symbols came from a file and change the amounts of options every day. I woul like to resize this 3 dimension matrix each time that my ea read the file.
I can't resize in 2 or 3 dimension, but if I leave a fixed matrix it consumes a absurd of ram memory.
 
Eric Sebestyen Ferreira #: So what would you recommend Inbmy problem? I have  up to 400 symbols each one has up 40 months and each month I have up 300 options symbols with up to 30 parameters each, like (expire date, strike, price, volumes...). The symbols came from a file and change the amounts of options every day. I woul like to resize this 3 dimension matrix each time that my ea read the file. I can't resize in 2 or 3 dimension, but if I leave a fixed matrix it consumes a absurd of ram memory.

As I explained, without knowing your exact details, I am unable to say. All I can say is that you should study up on Structures, Arrays of Structures, Dynamic allocations of those arrays and also to look into Classes to tie everything up into a neat organised bundle.

For example, as a simplified look at what you described, I would build a structure (or class) for each subset of the data and then build on that using dynamic allocation for each level (or dimension) of the data.

However, I am not here to code it for you, only to offer you some advice or guidance of what to study in order for you to do it yourself. I am assuming that you don't intend to hire anyone to do it for you, so your only option is to keep studying it until you can organise your code better.