hickscorp
6th December 2006, 23:11
Hello again people,
I have created long time ago some code which overloads new, new[], delete and delete[] operators, and which keeps track of allocated / freed memory in a std::map stuff.
My problem is, that i'm trying to use my code in my new QT application, and the result is that i get some warnings on memory leaks which i don't understand:
for instance, if in my main window object i do:
QTreeWidgetItem* pItmToAdd = new QTreeWidgetItem(pParent);
Do i have to delete it then? Or will QT handle this itself when "destructing" the parent QTreeWidget?
I have the very same problem each time i "new" an object which herits of QObject:
I have made some little KIO-like listers which are all derived from a class IFilesLister. So i get CFilesLister_File, CFilesLister_FTP, etc... The thing is, that in my application i do construct them this way:
IFilesLister* pLocalLister = new CFilesLister_FTP();
and in the main window's destructor i do:
delete pLocalLister;
Then, my log shows the constructor AND destructor as well:
Dbg> -> An [_FTP] Files Lister object is being constructed.
Dbg> Creating an instance of the internal FTP object...
Dbg> The [_FTP] Files Lister is initializing it's slots...
Dbg> <- The [_FTP] Files Lister object was created.
Then later:
Dbg> -> Destructing the main application Dialog.
Dbg> -> The [_FTP] Files Lister object is destroying...
Dbg> <- The [_FTP] Files Lister object was destroyed.
Dbg> <- Done destructing the main application Dialog.
So i have the "debug" proof that my objects get actually destroyed, but my memory leaks tracking system still anoys me with warnings on those pointers...
The only explaination i have is, that because the objects pointed by my leaks manager are all derived from QObject, maybe QT delete them itself before...
Any idea on how to solve this?
Bye!
Pierre.
[EDIT:]
Here is a sample output of my leaks tracking system:
Dbg> -> Probable Memory Leaks Listing:
Dbg> Src/CWndMainImpl.cpp:42 0x136736944, 36 byte(s).
Dbg> Src/CWndMainImpl.cpp:33 0x136738728, 20 byte(s).
Dbg> Src/CWndMainImpl.cpp:64 0x136816616, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:72 0x136818288, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:90 0x136820016, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:98 0x136821392, 32 byte(s).
Dbg> <- Total: 6 non-freed block(s), 184 byte(s)
Which ALL are "new"ed objects, either "native" QT or derivated from QObject...
I have created long time ago some code which overloads new, new[], delete and delete[] operators, and which keeps track of allocated / freed memory in a std::map stuff.
My problem is, that i'm trying to use my code in my new QT application, and the result is that i get some warnings on memory leaks which i don't understand:
for instance, if in my main window object i do:
QTreeWidgetItem* pItmToAdd = new QTreeWidgetItem(pParent);
Do i have to delete it then? Or will QT handle this itself when "destructing" the parent QTreeWidget?
I have the very same problem each time i "new" an object which herits of QObject:
I have made some little KIO-like listers which are all derived from a class IFilesLister. So i get CFilesLister_File, CFilesLister_FTP, etc... The thing is, that in my application i do construct them this way:
IFilesLister* pLocalLister = new CFilesLister_FTP();
and in the main window's destructor i do:
delete pLocalLister;
Then, my log shows the constructor AND destructor as well:
Dbg> -> An [_FTP] Files Lister object is being constructed.
Dbg> Creating an instance of the internal FTP object...
Dbg> The [_FTP] Files Lister is initializing it's slots...
Dbg> <- The [_FTP] Files Lister object was created.
Then later:
Dbg> -> Destructing the main application Dialog.
Dbg> -> The [_FTP] Files Lister object is destroying...
Dbg> <- The [_FTP] Files Lister object was destroyed.
Dbg> <- Done destructing the main application Dialog.
So i have the "debug" proof that my objects get actually destroyed, but my memory leaks tracking system still anoys me with warnings on those pointers...
The only explaination i have is, that because the objects pointed by my leaks manager are all derived from QObject, maybe QT delete them itself before...
Any idea on how to solve this?
Bye!
Pierre.
[EDIT:]
Here is a sample output of my leaks tracking system:
Dbg> -> Probable Memory Leaks Listing:
Dbg> Src/CWndMainImpl.cpp:42 0x136736944, 36 byte(s).
Dbg> Src/CWndMainImpl.cpp:33 0x136738728, 20 byte(s).
Dbg> Src/CWndMainImpl.cpp:64 0x136816616, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:72 0x136818288, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:90 0x136820016, 32 byte(s).
Dbg> Src/CWndMainImpl.cpp:98 0x136821392, 32 byte(s).
Dbg> <- Total: 6 non-freed block(s), 184 byte(s)
Which ALL are "new"ed objects, either "native" QT or derivated from QObject...