This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Memory issues (and leaks) in build 203Back to topics list |
|
Ruby
2007.04.23 19:08
Hi MetaQuotes,
Here is a very simple code (implemented as indicator) which heavily increases the computer's memory consumption. I only calls the iTime function in a loop. Can you tell me what the problem is? Thanks Ruby
#property indicator_separate_window
#property indicator_buffers 0
string symbols[6];
int timeframes[6];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
symbols[0] = "EURUSD";
symbols[1] = "USDJPY";
symbols[2] = "GBPUSD";
symbols[3] = "USDCHF";
symbols[4] = "GBPJPY";
symbols[5] = "USDCAD";
timeframes[0] = PERIOD_M1;
timeframes[1] = PERIOD_M5;
timeframes[2] = PERIOD_M15;
timeframes[3] = PERIOD_M30;
timeframes[4] = PERIOD_H1;
timeframes[5] = PERIOD_H4;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
for (int i = 0; i < ArraySize(symbols); i++)
{
for (int j = 0; j < ArraySize(timeframes); j++)
{
iTime(symbols[i], timeframes[j], 0);
}
}
return (0);
}
|
|
Slawa
2007.04.23 20:05
Of course increases. All requested historical data saved in the memory until release with EA/custom indicator/script unload.
There are no memory leaks. |
|
Ruby
2007.04.23 20:26
Of course increases. All requested historical data saved in the memory until release with EA/custom indicator/script unload. There are no memory leaks. Thanks Slawa, Even when removing the indicator, the memory doesn't get back to it's initial state. Besides, this data saved in memory for what purpuse? Ruby |
|
Ruby
2007.04.23 20:33
Of course increases. All requested historical data saved in the memory until release with EA/custom indicator/script unload. There are no memory leaks. Slawa, Sorry, but please check out the attached code. It seems like a memory leak / bug. I'm using a local variable t to keep the iTime function value, and still the memory is going higher just up as before. Thanks again, Ruby
#property indicator_separate_window
#property indicator_buffers 0
string symbols[6];
int timeframes[6];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void init()
{
symbols[0] = "EURUSD";
symbols[1] = "USDJPY";
symbols[2] = "GBPUSD";
symbols[3] = "USDCHF";
symbols[4] = "GBPJPY";
symbols[5] = "USDCAD";
timeframes[0] = PERIOD_M1;
timeframes[1] = PERIOD_M5;
timeframes[2] = PERIOD_M15;
timeframes[3] = PERIOD_M30;
timeframes[4] = PERIOD_H1;
timeframes[5] = PERIOD_H4;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
datetime t;
for (int i = 0; i < ArraySize(symbols); i++)
{
for (int j = 0; j < ArraySize(timeframes); j++)
{
t = iTime(symbols[i], timeframes[j], 0);
}
}
return (0);
}
|
|
Slawa
2007.04.24 09:22
Even when removing the indicator, the memory doesn't get back to it's initial state. Besides, this data saved in memory for what purpuse? Released in 5 minutes after EA/indicator/script unload. Information saved in memory for next possible requests |
|
Ruby
2007.04.24 14:33
Slawa,
From MT4 help: Local variables are stored in memory area of the corresponding function. Why this code doesn't free memory? I'm using a local variable.
int start()
{
datetime t;
for (int i = 0; i < ArraySize(symbols); i++)
{
for (int j = 0; j < ArraySize(timeframes); j++)
{
t = iTime(symbols[i], timeframes[j], 0);
}
}
return (0);
}
|
|
Slawa
2007.04.24 14:41
You call iTime function therefore You request for the all accessible data (max bars in the chart) of the appropriate symbol-timeframe
|
|
Ruby
2007.04.24 16:16
You call iTime function therefore You request for the all accessible data (max bars in the chart) of the appropriate symbol-timeframe 1. Does the same happen when calling iBars, iCustom, etc. (all "i" functions)? 2. Is there a workaround to programmatically free unused memory (garbage collection)? |
|
Ruby
2007.04.24 16:39
Slawa,
I've just checked it in build 201 and it behaves much better. |
|
Slawa
2007.04.25 10:48
1. Yes
2. No |
|
Slawa
2007.04.25 10:53
Slawa, I've just checked it in build 201 and it behaves much better. Compare bars count on the chart |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
