Results 1 to 3 of 3

Thread: memory problem with curves in plots

  1. #1
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default memory problem with curves in plots

    We've deprived curve like this,
    Qt Code:
    1. class BaseCurve : public QObject, public QwtPlotCurve
    2. {
    3. Q_OBJECT
    4. LOG4QT_DECLARE_QCLASS_LOGGER
    5. ..........
    6. ~BaseCurve();
    7. private:
    8. ..
    9. QList<QwtPlotMarker *> m_markerList ;// some plot items in the curve.
    10. ..
    11. }
    12. BaseCurve::~BaseCurve() {
    13. foreach (QwtPlotMarker *marker, foreach m_markerList}) {
    14. delete marker;
    15. }
    16. }
    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?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: memory problem with curves in plots

    Don't have a good link at hand, but malloc/free are no system calls ( maybe google for sbrk+malloc to understand how it works ).

    Better do your test in a loop. When everything is o.k. you will see, that the value shown by htop won't grow with every loop as the memory freed from the previous loop will be reused.

    Uwe

  3. #3
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: memory problem with curves in plots

    oh, I see.
    what do you think of the way we deprive basecurve from QObject and QwtPlotCurve ? Is it ok ?
    Do you think that we have all the items deleted this way?

Similar Threads

  1. Replies: 1
    Last Post: 23rd January 2014, 01:27
  2. Replies: 3
    Last Post: 8th April 2013, 07:06
  3. Memory management problem
    By zloigall in forum Newbie
    Replies: 4
    Last Post: 25th July 2012, 16:16
  4. Qt Memory size problem ?
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 29th September 2008, 15:27
  5. Virtual memory problem
    By Rahul in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2007, 13:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.