MarketData.GetTicks() doesn't release memory

Created at 29 Sep 2022, 11:20
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
YR

YrpWayne

Joined 06.03.2019

MarketData.GetTicks() doesn't release memory
29 Sep 2022, 11:20


Hi, I've been working on a robot and ran into a memory problem. Diagnosing the cause lead me to

protected override void OnStart()
{
    var ticks = MarketData.GetTicks();
}

I found that after calling GetTicks(), there is no way to release the object and it just keeps appending each new tick to its backing field. While I'm sure that's useful for some people I'm only calling the function to get the historical ticks initially so I can prepopulate my indicators before starting the robot. Afterwards, the OnTick() function does the trick for me.

Is there a way to get the historical tick data during OnStart() and then release the object in a way that will stop it from growing in the back end?

 

As an example of the memory usage for ~10 months of tick data on EURUSD I consume just shy of 13GB of ram. Makes it hard to do Optimizations.

 

A simple example of the problem (backtest for ~9 months):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class DebugTool : Robot
    {
        protected override void OnStart()
        {
            var ticks = MarketData.GetTicks();  // Comment out this line to see the difference.
        }

        protected override void OnTick()
        {
        }

        protected override void OnStop()
        {
        }
    }
}

 


@YrpWayne