Idenfity reason for "out of memory"

 

Hi,

 

my EA seems to have a memory leak since after a while it crashes with "out of memory".  How can I figure out which statement in my EA consumes memory and does not release it afterwards?

 

In my EM I have a function which is frequently invoked and which contains the following code:

 

MACDHandle=iMACD(_Symbol,period,fast_ema_period,slow_ema_period,signal_period,applied_price);

   ArraySetAsSeries( MACDValue,true );     // Set the MACD to timeseries, 0 is the oldest. 

   if( CopyBuffer( MACDHandle,0,0,5,MACDValue ) > 0 ) // Copy value of MACD to MACDValue

      {

            MACDReturnValue = MACDValue[0]; // Print the value of the MACD

          ...

} 

 

May it be possible that memory is lost here? If so, how can I release it again?

Best,

Chris 

 
zubr:

Hi,

 

my EA seems to have a memory leak since after a while it crashes with "out of memory".  How can I figure out which statement in my EA consumes memory and does not release it afterwards?

 

In my EM I have a function which is frequently invoked and which contains the following code:

 

 

May it be possible that memory is lost here? If so, how can I release it again?

Best,

Chris 

Hi, This sounds similar to this: https://www.mql5.com/en/forum/12809

So I believe that it might be caused by a bug if you are releasing the indicator handle somewhere in your code. If you are maybe you could try to remove this process from your code and see if that helps :)

Candles

Re-initialization of an indicator
Re-initialization of an indicator
  • www.mql5.com
Do I have to, or can I manually not only release the indicator, but also the memory it used?
 
Candles:

Hi, This sounds similar to this: https://www.mql5.com/en/forum/12809

So I believe that it might be caused by a bug if you are releasing the indicator handle somewhere in your code. If you are maybe you could try to remove this process from your code and see if that helps :)

Candles

I did some more debuggin. My problem is the following code that is inside a frequently invoked function:

 

   double high[];
   double low[];
   
   int copiedDataCountHigh = CopyHigh(currentSym, InpPeriod, 0, DonchianPeriod, high);
   int copiedDataCountLow = CopyLow(currentSym, InpPeriod, 0, DonchianPeriod, low);

 When I remove the invocation of CopyHigh and CopyLow than I have no "out of memory" errors. 

Is there a problem with non-released memory? If so, how can I release it? I tried ArrayFree() but this did not work. 

 

Try to limit the array size of high[]/low[]:

   double high[1000];
   double low[1000];
   
   int copiedDataCountHigh = CopyHigh(currentSym, InpPeriod, 0, DonchianPeriod, high);
   int copiedDataCountLow = CopyLow(currentSym, InpPeriod, 0, DonchianPeriod, low);
 
luenbo:

Try to limit the array size of high[]/low[]:

This does not help. Even if I limit the array size to 20, I get "out of memory" after a while.
 

This really sounds related to my problem that Candles mentioned earlier on.

So far the service desk status is "we reproduced it and are working on it".

Hopefully, once the solve this issue, both of our problems are gone.

 
Clock:

This really sounds related to my problem that Candles mentioned earlier on.

So far the service desk status is "we reproduced it and are working on it".

Hopefully, once the solve this issue, both of our problems are gone.

This problem seems different, your "bug" is with IndicatorRelease().
 
zubr:
This does not help. Even if I limit the array size to 20, I get "out of memory" after a while.
Can you post a code that compiles and reproduce your issue ?
 
angevoyageur:
Can you post a code that compiles and reproduce your issue ?

This is the code in short resulting after approx. 6 min running to an out of memory:

 

input int DonchianPeriod=20;            //Period of averaging
input ENUM_TIMEFRAMES InpPeriod=PERIOD_D1; // Period
string currentSymbol;

int OnInit()
  {
   while(true) {
   for(int i = 0; i < SymbolsTotal(true); ++i )
   {
      currentSymbol = SymbolName(i, true);
      Print(currentSymbol);
      checkDonchian(currentSymbol);
   
      Sleep(1000);
   }
   Sleep(1000);
   } 
   
//---
   return(INIT_SUCCEEDED);
  }

int checkDonchian(string currentSym)
{

   double SsMax=0,SsMin=0;
 
   double high[];
   double low[];
   
   int copiedDataCountHigh = CopyHigh(currentSym, InpPeriod, 0, DonchianPeriod, high);
   int copiedDataCountLow = CopyLow(currentSym, InpPeriod, 0, DonchianPeriod, low);
   
   return 0;
}
 
zubr:

This is the code in short resulting after approx. 6 min running to an out of memory:

 

Are you talking of 6 min on a live chart ?
 
angevoyageur:
Are you talking of 6 min on a live chart ?

I mean when I attach the EA to a chart it crashes after about 6 minutes (depends on current system usage). Can you reproduce it? 

Reason: