RoboForex cTrader 4.0 freezes when printing many log messages

Created at 19 Apr 2021, 09:03
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!
CT

ctid2032775

Joined 03.05.2020

RoboForex cTrader 4.0 freezes when printing many log messages
19 Apr 2021, 09:03


Dear all,

while developing my cBots I usually print quite some messages to analyze the different states of the algorithm and get more "debug" information. Since upgrading to 4.0 I am facing the following issue:

  • The cBot starts working normally, runs fast and cTrader Desktop is responsible for any user interaction
  • After some time - and after printing a lot of log lines - the cBot seems to stop running and the frontend freezes (even Ctrl-Alt-Shift-T isn't possible)
  • In the task manager I can see that the memory consumption dramatically increases
  • And the only way to stop this is to kill the cTrader task

Is there any limit for writing to the log or any way to prevent the cBot to run into this issue?

Or could this be a bug of the latest version (4.0.7.48410)?

Many thanks for your assistance and best regards,
Christian


@ctid2032775
Replies

PanagiotisCharalampous
19 Apr 2021, 10:10

Hi ctid2032775,

Can you share your cBot code? We will need it to investigate further.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

ctid2032775
19 Apr 2021, 20:55

RE:

PanagiotisCharalampous said:

Hi ctid2032775,

Can you share your cBot code? We will need it to investigate further.

Best Regards,

Panagiotis 

Join us on Telegram

Hi Panagiotis,

it doesn't seem to be related to the trading algorithm - I was able to reproduce it even with a very simple OnStart function:

protected override void OnStart()
{
    for (int i = 0; i < 100; i++)
    {
        for (int j = 0; j < 100; j++)
        {
            for (int k = 0; k < 100; k++)
            {
                Print("Cascaded loop: i = {0} - j = {1} - k = {2}", i, j, k);
            }
        }
    }
}

Right now I could see the same behavior in the latest Public Beta 4.0...

In addition to that it's confusing that even such a "primitive" functionality produces high CPU load - in my case it was more than 30% on a virtual machine with 6 (virtual) processors (host CPU is i5-10600K) and 8 GB memory.

Many thanks and regards,
Christian


@ctid2032775

PanagiotisCharalampous
20 Apr 2021, 08:21

Hi ctid2032775,

I am not sure what do you expect to happen or what do you mean by "primitive" functionality. It is one million instructions that need to be executed and the result stored in memory and logged in a file. I would expect some load on the computer.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

ctid2032775
20 Apr 2021, 09:14

RE:

PanagiotisCharalampous said:

Hi ctid2032775,

I am not sure what do you expect to happen or what do you mean by "primitive" functionality. It is one million instructions that need to be executed and the result stored in memory and logged in a file. I would expect some load on the computer.

Best Regards,

Panagiotis 

Join us on Telegram

Hi Panagiotis,

sorry for the hard wording ;-) but I didn't expect a simple loop with just a print command to generate such a high CPU load (the memory consumption is logical)...

Could you reproduce the freezing of the frontend?
Is this a "normal" behavior and needs to be prohibited by the cBot functionality (e. g. reducing the number of logged information or regularly deleting the log)?
If yes - is there a way to realize a "rolling" log (i. e. deleting "older" messages when the size of the log exceeds a certain amount of text)?

Many thanks for your support and best regards,
Christian


@ctid2032775

PanagiotisCharalampous
20 Apr 2021, 11:15

Hi ctid2032775,

Any loop will generate a high CPU demand, that is the purpose of the CPU anyway, to do things as fast as possible.

Could you reproduce the freezing of the frontend?

Yes but this is expected, since cBots are executed on the same thread as the main UI. We will change this in future versions, allowing resource intensive Automate code to be executed on separate threads, thus not blocking the UI.

Is this a "normal" behavior and needs to be prohibited by the cBot functionality (e. g. reducing the number of logged information or regularly deleting the log)?

The responsibility for efficient programming lies on the developer. If your code, consumes a lot of resources and causes the hosting application to be unresponsive, then you need to optimize your code.

If yes - is there a way to realize a "rolling" log (i. e. deleting "older" messages when the size of the log exceeds a certain amount of text)?

If I am not mistaken, there is a limit to how many messages can be printed inside cTrader.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

Shares4us
22 Jul 2021, 17:54

RE:

A workaround is just to dump it in a file line by line or f.i. every thousand lines.
 

 


@Shares4us