PDA

View Full Version : 'memory leak' threads on QT centre



locus
29th January 2007, 18:36
I have read all the threads, but none seem to answer, specifically, the questions i have, so i decided to ask them here:


Am i leaking memory by writing my code as follows:






class QDataWidgetMapper ;
class QSqlTableModel;
class QHeaderView ;

class SomeClass : public QDialog, public Ui_SomeForm
{
Q_OBJECT

.......



private:
QDataWidgetMapper *mapper;
QSqlTableModel *model;
QHeaderView *header;
....
};

and in my constructor of SomeClass the pointers are all initialized as follows:


SomeClass::SomeClass(QWidget *parent )
: QDialog(parent)
{
setupUi(this);

......


model = new QSqlTableModel(this);
header = new QHeaderView(Qt::Horizontal,this);
mapper = new QDataWidgetMapper(this);

.....
}


I do not call delete on any of these pointers. Am i doing something wrong here? Oh and i never get errors on memory leaks, i am just really trying to make sure i am not creating any.

Also, where would you recommend that i call delete?

I am using MSVS .NET 2003, with the QT-VS integration;

if i do have memory leaks, could you direct me to some fast and accurate debug application that i can run in .NET, that will help me to identify them?

also, if memory leaks occur while my programs run, is it a FACT that after the program closes the memory is returned to the operating system?

thanks in advance for your attention, your time is valuable and it is appreciated.

jacek
29th January 2007, 18:44
Every QObject that has a parent will be deleted when its parent gets destroyed.