I am having an issue where it seems there is a memory leak.
I'm struggling with it for two days and I would like to ask you for some support because I don't know what else I can check.
This is my scenario:
In some condition I am opening a new window, where I am plotting a QCustomPlot graph.
Moreover, in my application a function is running every second in polling logic, let's call it "trigger function", in order to refresh my data in the plot.
After many seconds (so after many triggers received) I noticed a small increase of the memory allocated by my application.
I isolated every code block step by step, and at the end of the day the code block creating me this issue is the one added below.
When I refresh my data, I am usingan "update function" where I am using something like this:
ui->Graph1_Trend->graph(0)->setData(x, y); ui->Graph1_Trend->graph(1)->setData(x, y_H_Th); ui->Graph1_Trend->graph(2)->setData(x_err, y_err); ui->Graph1_Trend->graph(3)->setData(x, y_Warning_Th); ui->Graph1_Trend->graph(4)->setData(x_warning, y_warning);
If I skip exactly these 4 code rows, my issue disappear, so I am sure it related to the QCustomPlot data setting.
Let me add one more thing, that makes me more confused:
The secondary page where I plot my data is opened setting Qt::WA_DeleteOnClose in the constructor.
If I refresh my data with the trigger function ( let's say 100 times), as soon as I press "close page", it works perfectly and the memory is freeed.
But if I send 1000 triggers, after pressing "close page", the programs freeezes for a while.
If I increase the amount of triggers, the freezing time increases.
In few words, it seems that if I close the page, trying to free the memory used for the "setData", the program is having trouble an it's taking much time to free the memory.
Once again I tried to isolate the issue:
* if the page is not set as Qt::WA_DeleteOnClose, this freezing is not happening.
* This (freezing time after "close page" press) is not happening even if I set the attribute Qt::WA_DeleteOnClose on active, and meanwhile I skip the 4 code rows posted above where I am setting the data for the plot.
For these reasons I am sure the issue is related to the previous one (the memory leak beahaviour described before), and both of them are in such a way related to the setData function.
Can you please help me in finding out a solution for these connected behaviours?