memory leak in build 200

 
I have been running the same EA for six months with no problems at all and then with the upgrade to build 200 a severe memory leak began. Within a matter of hours all 2GB of memory and 4GB of paging file have been used on my computer and I receive this error over and over again:

no memory for temp string

I reinstalled older versions of 197 and 198 and the EA runs perfectly and uses almost no memory. How do we find and fix the problem in 200?
 
Try to recompile your EA with last compiler.
 
What do you mean? I am compliling it with the compiler that came with build 200, "MetaEditor Version 4.00 build 200 (Nov 15 2006)" is what it says in Help > About. Is there a different version I should be using?
 
Can You send source of your EA for investigation? I guarantee confidentiality and will remove your source after researching. stringo AT metaquotes.ru
 
Could you keep me in touch with this topic too? I believe there is a memory leak of somekind that is somehow resolved with resetting the Terminal.exe. I was also asked to send in a copy of my EA but am under obligation of confidentiality in respects to my own clients.

However, I've noticed that a problem has existed since an update around the time of July of this year. The trade station trades less and less as time goes by. Just as soon as the station is reset, trades pop in more frequently. I have a simple channel trader that drops pending orders. Just as soon as the pending orders are filled and go out, new ones are created. It is interesting to see the new pending orders all the sudden start popping in as soon as the terminal.exe is turned off and back on.

All of my systems run on the simple method of reviewing current orders and pending orders using the OrderSelect command. If orders exist, no new ones are created. So if it works once, it should be working consistantly all the time, without having to reset the terminal.exe.

Could the two problems mentioned in this post be related?

Я говорю нимного порусский если то легке. Никто не ответили моей почте поанглиский.
 
Unfortunately, I cannot post the code I am using either as it is under copyright and I cannot redistribute it. I have been doing some testing myself, and by process of elimination I think the problem may be related to creating/printing a StringConcatenate every time a function runs. I have not had enough time to thoroughly test it at this point, but I will post my findings and if I can narrow it down to a section of code I will send that piece in for review.

Slawa - Are there more advanced debugging tools or a developer's version of MetaTrader available that would help me find the source of the leak? Are there any resources available as a 'How To' guide to finding such problems?
 
Some code lines illustrated problem are appreciated.
 
1. allow the system to create a pending order
2. allow the system to open the pending order and close the order
3. time how long the system takes to create a new pending order
4. if you have time, build a ratio chart based on the time it takes to open a new order against the total time the system has been running.

1. allow the system to create a pending order
2. allow the system open pending order and close the order
3. close terminal.exe and reopen it
4. notice that the pending order is created immediately

I have a number of scripts that run on multiple currencies simutaneously. The code I've presented below has been tweaked for over a hundred scripts I've written. All of my scripts lag in reopening orders since around July of this year.

Now I use an external program to restart terminal.exe every hour and the problem does not exist.

*** sample code fragment
 for (int cnt = 0; cnt < total; cnt++) 
   {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    
    if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == Identification)
    {
     ActiveTrades = ActiveTrades + 1;
    } // review pending BUY orders

    if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == Identification)
    {
     ActiveTrades = ActiveTrades + 1;
    } // review pending sell orders

     if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Identification)
    {
     ActiveTrades = ActiveTrades + 1;
    } // review open buy orders

    if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == Identification)
    {
     ActiveTrades = ActiveTrades + 1;
    } // review open sell orders

   } // review all active orders

if (ActiveTrades == 0 && Bank() > 0)
    {
     OpenOrder(Symbol(), TradeChart, Identification);
    } // Identification

return(0)



*** sample OpenOrder function

void OpenOrder(string tradesymbol, int tradechart, int magicnumber)
  {
    ticket = OrderSend(tradesymbol, OP_BUYSTOP, LotSize(), Ask + 15 * MarketInfo(tradesymbol, MODE_POINT), OpenSlippage, (Ask + 15 * MarketInfo(tradesymbol, MODE_POINT)) - (StopLoss * MarketInfo(tradesymbol, MODE_POINT)), (Ask + 15 * MarketInfo(tradesymbol, MODE_POINT)) + (TakeProfit * MarketInfo(tradesymbol, MODE_POINT)), openname, magicnumber, 0, Green);
  } // OpenOrder



 
Slawa - I am sending you the stripped down code that I am having problems, it is essentially doing the same thing as fmeetze's code. it just seems like it is not releasing the memory space from the OrderSelect function. When I test in build 198 terminal.exe's memory will increase to about 40MB and then return to about 2MB and then repeat...in build 200 the memory just increases until my computer crashes...it never releases. I have emailed you the code.
 
Thank You, benomatron. I'll check
 
I cannot detect memory leaks. I've used standard debugger, memory validator and bounds checker. No memory leaks.

In build 200, the tick modelling algorithm has been changed. The amount of ticks generated is now about 1.5-2 times more than before. If you want to free memory after testing, close the Tester window and then reopen it.

I have removed your source code already.
Reason: