I got error message: "12 leaked strings left" on deinit

 

I got this error message: "12 leaked strings left" when I remove my indicator.

What do I do wrong?

Thanks for your help

 
melgibson:

I got this error message: "12 leaked strings left" when I remove my indicator.

What do I do wrong?

Thanks for your help

Can you show the relevant code ?
 
angevoyageur:
Can you show the relevant code ?

I too have received a similar Warning Message

egs

121 leaked stings lefft

2 leaked strings left etc etc

The 'reason' is buried' somewhere within 500 lines of code.

Note that I am utilizing numerous string arrays

Any hints on where to look?

 
Please create a Service Desk request and attach the code necessary for reproducing this behaviour, so that we can check the issue.
Your code will be deleted after the check.

You can send me a private message instead of applying to Service Desk.
 
mql5:
Please create a Service Desk request and attach the code necessary for reproducing this behaviour, so that we can check the issue.
Your code will be deleted after the check.

You can send me a private message instead of applying to Service Desk.


I'd be interested to learnt the meaning of the warning message

The code was in Alpha. I have since modified the code and the warning messages have disappeared, for reasons that I am unable to determine.

 

Hello,

you can dublicate "1 leaked strings left" where custom indicator have a code:

struct   s_lines

{

  string   lineN;

};

s_lines  line[1];

int OnInit()

{

  for (int i=0;i<1;i++)

    //line[i].lineN = StringFormat("as_%s","aaa");

    line[i].lineN = StringConcatenate("as_","aaa");

  return(INIT_SUCCEEDED);

}

 

I have the same problem with "leaked strings left"

Im using using structures to allow for database row type arrays. 

//+------------------------------------------------------------------+
//| Structure for storing trendline data                                 |
//+------------------------------------------------------------------+
struct trend
  {
   string            name; 
   double            price1; 
   double            price2;   
   datetime          time1; 
   datetime          time2; 
   int               style;    
   int               thinkness; 
   int               timeframes; 
   color             line_color;
   string            discription;
   string            breakage;
  };
 
Im thinking its something to do with ArraySize as to reset the arrays I am using. ArrayResize(array_name,1);
 

This problem appears to be back after the last update. The last update installed today:

// Reported issues during last compile:
// 2023.09.25 22:29:29.392    LRSF_405 (EURZAR,H4)    2 leaked strings left
// 2023.09.25 22:29:29.403    LRSF_405 (EURZAR,H4)    5 undeleted objects left
// 2023.09.25 22:29:29.403    LRSF_405 (EURZAR,H4)    3 objects of type cl_timer left
// 2023.09.25 22:29:29.403    LRSF_405 (EURZAR,H4)    2 objects of type cl_ma left
 

This is connected to undeleted objects which causes memory leak once the EA finishes (OnDeinit() function call).

I've had a lot of problems with this in the past 90 minutes.

Here's what fixed it for me.

for ( i = 0, pNodeHL = pListHL.GetFirstNode(); pNodeHL != NULL; pNodeHL = pListHL.GetNextNode() )
        {
                pObjArrow = pNodeHL.GetObjArrow();
                if ( CheckPointer( pObjArrow ) == POINTER_DYNAMIC )                             // This.  Works.  No memory leak.
                        delete pObjArrow;

                if ( CheckPointer( pObjArrow ) != POINTER_INVALID  )
                {
                        sObjName = pObjArrow.Name();
                        ObjectDelete( 0, sObjName );
                        Print( __FUNCTION__, " TEST: trying to delete object: ", sObjName, "." );               // "n leaked strings left + n undeleted objects left"
//***************************************************
                        if ( pObjArrow.Delete() )                                       // "n undeleted objects left, x bytes of leaked memory"
                                i++;
                        else
                        {
                                Print( __FUNCTION__, " TEST: cannot delete CChartObjectArrow object pointer: ", pObjArrow.Name(), "." );                // I don't think this ever happened, so the Delete() function - in theory - worked
                                ObjectDelete( 0, sObjName );
                        }
                }
        }
        if ( i )
                Print( __FUNCTION__, " TEST: deleted ", IntegerToString( i ), " CChartObjectArrow object pointer(s)." );
//***************************************************
        for ( j = 0, i = ObjectsTotal( 0, 0, OBJ_ARROW ) - 1; i >= 0; i-- )             // the oldschool method, "n undeleted objects left, x bytes of leaked memory", it couldn't even find the necessary objects (so they were probably deleted with pObjArrow.Delete() )
        {
                sObjName = ObjectName( 0, i, 0, OBJ_ARROW );
                if ( StringFind(sObjName, "Arrow_") == -1 )                     //just to make sure it does what it is supposed to
                        continue;
                if ( ObjectFind( 0, sObjName ) > -1 )
                {
                        ObjectDelete( 0, sObjName );j++;
                }
        }
        if ( j )
                Print( __FUNCTION__, " TEST: deleted ", IntegerToString( j ), " Arrow object(s) from chart." );                 //never seen this message - couldn't find such objects
}