[Kget] Memory leaks?

Matthias Fuchs mat69 at gmx.net
Tue Apr 21 21:39:42 CEST 2009


Valgrind found some memory leaks, attached is some information -- no, not the 
complete output -- and thoughts. Maybe something of this is useful.

################
==9590== 14,276 (380 direct, 13,896 indirect) bytes in 19 blocks are 
definitely lost in loss record 89 of 187        
==9590==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-
linux/vgpreload_memcheck.so)              
==9590==    by 0x46DC5FE: TransferHistoryStore::getStore() 
(transferhistorystore.cpp:145)                            
==9590==    by 0x46CCD58: TransferGroup::remove(Transfer*) 
(transfergroup.cpp:122)                                   
==9590==    by 0x46C5BCA: TransferTreeModel::delTransfer(Transfer*) 
(transfertreemodel.cpp:77)                       
==9590==    by 0x46BAA58: KGet::delGroup(QString const&) (kget.cpp:141)                                              
==9590==    by 0x46BAD5A: KGet::deleteSelf() (kget.cpp:87)                                                           
==9590==    by 0x8098D6C: MainWindow::~MainWindow() (mainwindow.cpp:113)                                             
==9590==    by 0x809FA09: main (main.cpp:38)

In void TransferGroup::remove(Transfer * transfer)
TransferHistoryStore::getStore() is called and that creates a pointer with new 
that is not deleted afterwards. 


################
==9590== 17,350 (1,440 direct, 15,910 indirect) bytes in 9 blocks are 
definitely lost in loss record 124 of 187      
==9590==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-
linux/vgpreload_memcheck.so)              
==9590==    by 0x7DC1C66: TransferKioFactory::createTransfer(KUrl const&, KUrl 
const&, TransferGroup*, Scheduler*, QDomElement const*) 
(transferKioFactory.cpp:43)                                                                        
==9590==    by 0x46C0DB0: KGet::createTransfer(KUrl const&, KUrl const&, 
QString const&, bool, QDomElement const*) (kget.cpp:711)                                                                                                         
==9590==    by 0x46C1599: KGet::addTransfer(QDomElement const&, QString 
const&) (kget.cpp:227)                       
==9590==    by 0x46CBF1C: TransferGroup::load(QDomElement const&) 
(transfergroup.cpp:379)                            
==9590==    by 0x46BFCEA: KGet::load(QString) (kget.cpp:435)                                                         
==9590==    by 0x809D805: MainWindow::slotDelayedInit() (mainwindow.cpp:334)                                         
==9590==    by 0x809E081: MainWindow::qt_metacall(QMetaObject::Call, int, 
void**) (mainwindow.moc:164)               
==9590==    by 0x4B96C87: QMetaObject::activate(QObject*, int, int, void**) 
(in /usr/lib/libQtCore.so.4.5.0)         
==9590==    by 0x4B98411: QMetaObject::activate(QObject*, QMetaObject const*, 
int, void**) (in /usr/lib/libQtCore.so.4.5.0)                                                                                                               
==9590==    by 0x4B9C0F6: (within /usr/lib/libQtCore.so.4.5.0)                                                       
==9590==    by 0x4B9C21B: (within /usr/lib/libQtCore.so.4.5.0)

Because the static KGet members excluding m_scheduler are not deleted 
(m_transferTreeModel in this case)


################
==9590== 15,418 (140 direct, 15,278 indirect) bytes in 7 blocks are definitely 
lost in loss record 126 of 187        
==9590==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-
linux/vgpreload_memcheck.so)              
==9590==    by 0x7DC15D2: TransferKioFactory::createTransferHandler(Transfer*, 
Scheduler*) (transferKioFactory.cpp:50)                                                                                                                    
==9590==    by 0x46C79F8: Transfer::handler() (transfer.cpp:165)                                                     
==9590==    by 0x46C7A56: Transfer::setTransferChange(int, bool) 
(transfer.cpp:284)                                  
==9590==    by 0x7DC0176: TransferKio::start() (transferKio.cpp:38)                                                  
==9590==    by 0x46C43A6: Scheduler::updateQueue(JobQueue*) 
(scheduler.cpp:199)                                      
==9590==    by 0x46D3F1A: 
TransferGroupScheduler::jobQueueAddedJobEvent(JobQueue*, Job*) 
(transfergroupscheduler.cpp:39)                                                                                                                  
==9590==    by 0x46B94E1: JobQueue::append(Job*) (jobqueue.cpp:94)                                                   
==9590==    by 0x46CCFEF: TransferGroup::append(Transfer*) 
(transfergroup.cpp:98)                                    
==9590==    by 0x46C5ABC: TransferTreeModel::addTransfer(Transfer*, 
TransferGroup*) (transfertreemodel.cpp:64)       
==9590==    by 0x46C0FF2: KGet::createTransfer(KUrl const&, KUrl const&, 
QString const&, bool, QDomElement const*) (kget.cpp:714)                                                                                                         
==9590==    by 0x46C1599: KGet::addTransfer(QDomElement const&, QString 
const&) (kget.cpp:227) 

I did not look into this one but I guess that the problem is similiar to the 
one above.

################
==9590== 127,472 (116 direct, 127,356 indirect) bytes in 1 blocks are 
definitely lost in loss record 181 of 187      
==9590==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-
linux/vgpreload_memcheck.so)              
==9590==    by 0x515BC7F: QFontDatabase::load(QFontPrivate const*, int) (in 
/usr/lib/libQtGui.so.4.5.0)              
==9590==    by 0x51334DA: QFontPrivate::engineForScript(int) const (in 
/usr/lib/libQtGui.so.4.5.0)                   
==9590==    by 0x514DC31: QFontMetrics::height() const (in 
/usr/lib/libQtGui.so.4.5.0)                               
==9590==    by 0x521F16D: (within /usr/lib/libQtGui.so.4.5.0)                                                        
==9590==    by 0x5223E16: QCommonStyle::subElementRect(QStyle::SubElement, 
QStyleOption const*, QWidget const*) const (in /usr/lib/libQtGui.so.4.5.0)
==9590==    by 0x42162FA: KStyle::subElementRect(QStyle::SubElement, 
QStyleOption const*, QWidget const*) const (kstyle.cpp:3102)
==9590==    by 0x7DF89ED: OxygenStyle::subElementRect(QStyle::SubElement, 
QStyleOption const*, QWidget const*) const (oxygen.cpp:3353)
==9590==    by 0x551ECC1: QStyledItemDelegate::updateEditorGeometry(QWidget*, 
QStyleOptionViewItem const&, QModelIndex const&) const (in 
/usr/lib/libQtGui.so.4.5.0)
==9590==    by 0x546E899: QAbstractItemViewPrivate::editor(QModelIndex const&, 
QStyleOptionViewItem const&) (in /usr/lib/libQtGui.so.4.5.0)
==9590==    by 0x547518D: QAbstractItemView::openPersistentEditor(QModelIndex 
const&) (in /usr/lib/libQtGui.so.4.5.0)
==9590==    by 0x8073716: TransfersView::setModel(QAbstractItemModel*) 
(transfersview.cpp:76)

The Qt docu was not specific if one has to close the PersistentEditor.

################
==9590== 19,466 (1,020 direct, 18,446 indirect) bytes in 15 blocks are 
definitely lost in loss record 106 of 187     
==9590==    at 0x40277EE: operator new(unsigned) (in /usr/lib/valgrind/x86-
linux/vgpreload_memcheck.so)              
==9590==    by 0x4B94C50: QObject::QObject(QObject*) (in 
/usr/lib/libQtCore.so.4.5.0)                                
==9590==    by 0x46DAAC9: TransferHistoryStore::TransferHistoryStore() 
(transferhistorystore.cpp:126)                
==9590==    by 0x46DAB11: SQLiteStore::SQLiteStore(QString const&) 
(transferhistorystore.cpp:397)                    
==9590==    by 0x46DC60C: TransferHistoryStore::getStore() 
(transferhistorystore.cpp:145)                            
==9590==    by 0x46CCD58: TransferGroup::remove(Transfer*) 
(transfergroup.cpp:122)                                   
==9590==    by 0x46C5BCA: TransferTreeModel::delTransfer(Transfer*) 
(transfertreemodel.cpp:77)                       
==9590==    by 0x46BAA58: KGet::delGroup(QString const&) (kget.cpp:141)                                              
==9590==    by 0x46BAD5A: KGet::deleteSelf() (kget.cpp:87)                                                           
==9590==    by 0x8098D6C: MainWindow::~MainWindow() (mainwindow.cpp:113)                                             
==9590==    by 0x809FA09: main (main.cpp:38)

======

Additionally settings like void MainWindow::slotTransferGroupSettings()
in MainWindow are always recreated whenever you visited them but only deleted 
when closing KGet.




More information about the Kget mailing list