iCustom Loop Call & Memory

 
Read articles about, but no workaround found.
I've progressively extended my EA from Multitimeframe/One Pair to Multipair/Multitimeframe, no problem, it even worked during one complete week on demo. Then i decide to improve it a bit, and came the troubles.

Let say that EA intensively use icustom() calls to indicators with a shift=1, to work on finished bar.
No memory problem, it tooks about 400M to run 22 pairs, architectured around a central EA on a pair wich carries all computing tasks, and little connector (EA) droped on each of all other traded pair to carry on board drawing (objects) on each chart by use of global variables.
Believe me, it works, full of 4D arrays, plenty of global variables, but it works...

Then i decided to fasten decisions, by considering the becoming of each pairs/timeframes live bars.
So easy, just add needed arrays for results classification and twice call to the same iCustom() indicators, with shift=1 & shift=0. Done needed debugging to adjust decision rules syncing...and went to the strategy tester on a one pair/multitimeframe.

Then, just after ten or twenty bars tested, the whole collapsed, all RAM (1G) was eaten. After many readings, it came out that calls to iCustom() are really big memory consumming and may explain this issue.
But i can explain to myself why this EA worked before. Obviously one will say 400M for shift=1, add 400M for shift=0, you're nearly there...
Ok, if so, can one give confirmation of this, as to my point of view (some debug prints), iCustom() indicators are loaded at first call, and only deallocated at EA exit. Is it that each call load a new part of the same code in memory ?

Thanks for all.
 
If you pointed out that ICuston is eating memory, consider remove the ICustom and move the logic into the EA....
 
Did you find a solution to the problem? facing similar issues currently with nested iCustom calls leading to memory issues
Reason: