Could this be because of the "Max Bars in history/chart" setting within Options?
Yes.
- 'Max bars in chart' is a limit on the number of bars loaded in each opened chart. This directly affects memory. Limiting this would reduce memory usage and might solve your problem (which is memory related).
- 'Max bars in history' affects disk usage only (not memory); in most
cases u can set this to max value.
Thanks for the quick reply. I made this value lower and it certainly seemed to lower the initial memory used. However, I feel like the memory used will still increase at the same rate, wouldn't it? Doesn't this seem like a memory leak?
If some of the charts are not 'full' (are not yet filled with 'Max bars in chart' bars) then memory will slowly grow over time as more and more bars download. But eventually the charts will be full. From that point in time the platform should be stable memory wise.
Regarding possible memory leaks in your code. I can think of 2 possibilities:
- Endless recursive function calls.
- Using ArrayResize() with bigger and bigger sizes...
I noticed something else that seems to be happening ever since I resized Max Bars in Chart. The memory seems to skip around wildly. It went from 447 megs to 1 meg, back up to 447, etc.
There are tons of such ArrayResize calls in the code I use to help manage my orders - but I got it from mql4.com, so I figured that wouldn't cause it... I guess I will have to try to figure out where this occurs. Maybe you could take a quick look at it? Its the file I linked.
Maybe I wasn't clear... If buggy code causes an Array to be resized via ArrayResize() in such a way that it keeps growing (with no limit) then obviously that would be a 'memory leak'. But using ArrayResize() properly will not cause a memory leak.
Regarding the 'Event' code - looking at it briefly, it seems pretty generic stuff. Nothing to cause those kind of problems.
I noticed something else that seems to be happening ever since I resized Max Bars in Chart. The memory seems to skip around wildly. It went from 447 megs to 1 meg, back up to 447, etc.
Hi guys.I have the same problem with Allocation memory.I red lots of forums and did lots of solutions on my platform or my EA.I reduced numbers of bars on chart to as minimum as i need, for instance ,i use MA210 in my EA so i reduced the no.of bars to 220 .I'm using lots of indicator in my EA so they allocate lots of memory .I have changed even using MA to icustome to decrease the size of memory (decrease the numbers of bars that every MA uses).Also i did this on other indicators like SAR ,Bollinger,and etc.I want to use my EA on Numbers of currency pair or numbers of charts but after dragging EA on 4 charts This messageis coming into journal Tab and Ea didnt work on the last chart. What should i do? Do you Know any other solution ?
The message is: Array initialization:Cannot Allocate memory for 100000000 items.
Hi guys.I have the same problem with Allocation memory.I red lots of forums and did lots of solutions on my platform or my EA.I reduced numbers of bars on chart to as minimum as i need, for instance ,i use MA210 in my EA so i reduced the no.of bars to 220 .I'm using lots of indicator in my EA so they allocate lots of memory .I have changed even using MA to icustome to decrease the size of memory (decrease the numbers of bars that every MA uses).Also i did this on other indicators like SAR ,Bollinger,and etc.I want to use my EA on Numbers of currency pair or numbers of charts but after dragging EA on 4 charts This messageis coming into journal Tab and Ea didnt work on the last chart. What should i do? Do you Know any other solution ?
The message is: Array initialization:Cannot Allocate memory for 100000000 items.
What type is your array ? do you really need 100 million elements ?
Do not double and triple post . . . . I have deleted your other posts.
Thank for your quick reply.Type of my Arrays are Static int.Yeah i need my whole Arrays.Do you Know no: 100000000 refers to what? Is that the memory that my Arrays use it? How can i increase the memory that the platform use it? Also u used "#property stacksize 10240" but it didn't work well so.
An int is 4 bytes, so an array with 100 million elements such as . . .
int array[100000000];
. . will use 400 MB RAM approx, why does your array need to be 100,000,000 elements big ? are you declaring it as that size or resizing it ?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been working on an EA of mine for the past month or so. It works great in the strategy tester, so I decided to try it out on the live demo. However, after a few trades I get this message: "2010.04.26 18:51:58 Memory handler: cannot allocate 164202016 bytes of memory."
Also, when I open metatrader 4 the terminal.exe program uses way too much RAM (about 300 megs as indicated in the task manager); and when I insert my EA into a chart the RAM begins to grow with every tick. Could this be because of the "Max Bars in history/chart" setting within Options?
My EA iterates through multiple indicators and also uses Events.mq4 to keep track of orders. Here is the code for Events.mq4 which I feel may be the cause of the problem.
https://www.mql5.com/en/articles/mt4
And here is the link that describes it: https://www.mql5.com/en/articles/1399