MT5 memory leaks

 

Metatrader 5 seems that never release memory during script execution

even if i call delete function for dynamic pointers.

MT5 release memory only after then end of script .

During batch processes the memory consumption is increasing in Gigabytes and my system is slowing down.

 

In c++ everything is in local scope after the end of a function is released. 

Or you can use something like free or delete to release dynamic memory.

 

 Have you intension to improve memory managment in next releases ?

 

 Thanks in advance

 
pkoutsivitis:

Metatrader 5 seems that never release memory during script execution

even if i call delete function for dynamic pointers.

MT5 release memory only after then end of script .

It's not true.
 
Dynamic memory allocation in MQL5:
  1. When working with dynamic arrays, released memory is immediately returned back to the operating system.
  2. When working with dynamic class objects using the new operator, first memory is requested from the class memory pool the garbage collector is working with.
    If there is not enough memory in the pool, memory  is requested from the operating system.
    Garbage collector releases memory back to the operating system immediately after exiting the following event handling functions:

 

Thanks for your fast response.

 

I resolve it.

Finally was my fault. 

 

When running a eternal script, we only have one OnStart()

How memory is released to operating system? ArrayResize consume dynamic memory, how to force a garbage collector in this cases?

 
Roberto Spadim:

When running a eternal script, we only have one OnStart()

How memory is released to operating system? ArrayResize consume dynamic memory, how to force a garbage collector in this cases?

ArrayFree().