We've deprived curve like this,
{
Q_OBJECT
LOG4QT_DECLARE_QCLASS_LOGGER
..........
~BaseCurve();
private:
..
QList<QwtPlotMarker *> m_markerList ;// some plot items in the curve.
..
}
BaseCurve::~BaseCurve() {
delete marker;
}
}
class BaseCurve : public QObject, public QwtPlotCurve
{
Q_OBJECT
LOG4QT_DECLARE_QCLASS_LOGGER
..........
~BaseCurve();
private:
..
QList<QwtPlotMarker *> m_markerList ;// some plot items in the curve.
..
}
BaseCurve::~BaseCurve() {
foreach (QwtPlotMarker *marker, foreach m_markerList}) {
delete marker;
}
}
To copy to clipboard, switch view to plain text mode
Then we seem the BaseCurve as a plot item , when we close the plot, we first detach plot items which are inside the BaseCurve . We have checked very carefully to make sure every item created is deleted. But htop shows something's wrong, f.e, when we open the plot, memory consumption is 77 MB which would up to 135 MB after adding 100 BaseCurve into the plot. And it'll down to about 115 MB when closing the plot. Some memory taken by plot and basecurve are return to os, while some not.
We've used valgrind to check the code with no luck. Do you have some suggestion?
Bookmarks