Matthias Pospiech | 30 Apr 16:11
Picon
Picon

QwtRasterData *copy() does not delete data

When I use my spectrogram plot and plot a few 100 times, my memory is at 
its end.
This is caused by the copy of QwtRasterData :

    virtual QwtRasterData *copy() const
    {
        SpectrogramData *clone = new SpectrogramData();
        clone->setRangeX(m_RangeX.min, m_RangeX.max);
        clone->setRangeY(m_RangeY.min, m_RangeY.max);
        clone->setBoundingRect(QwtDoubleRect(m_RangeX.min, m_RangeY.min, 
m_RangeX.max, m_RangeY.max));
        clone->setData(m_Array, m_DataSize.x, m_DataSize.y);
        return clone;
    }

this calls setData which saves to array to the 'clone'

    void setData(double * Array, int sizex, int sizey)
    {
        int size = sizex * sizey;
        if (m_Array != NULL)
            delete [] m_Array;
        m_Array = new double [size];
        memcpy(m_Array, Array, size * sizeof(double));
    }

The clone always has m_Array == NULL, since it always created new. So

        m_Array = new double [size];
is always excecuted within the clone, but never deleted by the 
QwtRasterData class.

How do I solve this problem?

Matthias

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

Gmane