QTableWidget items Memory Leak Problem!
-
Hi~
I have QTableWidget and i am adding items through QTableWidgetItem ...
it has 10 column some hidden ..
everytime i add new row it increase the ram usage by 700kb to 2 megabytes ... so i think it's normal ~~
after almost 40 rows it became 130 megabytes of usage from (90 megabytes of normal usage of the software)
but when i need to reset QTablewidget and delete all the rows ~~
i used for that :ui->tableWidget->setRowCount(0);
but it stays 130 megabyte of ram usages ... it releases nothing ~~
if i add new rows ... it use more than 130 megabytes .. even closing the widget release only the widget and and the ram usage still higher!!!
i tried for loop with removeRow(i);
but the same problem !!!!
is there any solution?? -
@jsulm said in QTableWidget items Memory Leak Problem!:
@Proton-Phoenix said in QTableWidget items Memory Leak Problem!:
Task Manager
This is not a good tool to look for memory leaks. On Linux one would use Valgrind for example. Not sure what you can use on Windows. Maybe Visual Studio provides tools for that?
i found the memory leak bro
it was thisQSoundEffect effect; effect.setSource(QUrl::fromLocalFile("D:/**/**/**/**/barcode.wav")); effect.setLoopCount(1); effect.setVolume(0.40f); effect.play(); qDebug()<<effect.status(); // this the memory leak QEventLoop loop; loop.exec(); qDebug()<<effect.Error;
i used this to make a validation sound of adding values through barcode
it was keep using the ram more and more not QTableWidget at all
Thank you guys Really thank you -
Hi
Did you try calling clear() on the QTableWidget ?
https://doc.qt.io/qt-5/qtablewidget.html#clearAre you just adding text to the items ? as
130 mb for 40 rows x 10 cols seems a bit much for text. -
@mrjj said in QTableWidget items Memory Leak Problem!:
Hi
Did you try calling clear() on the QTableWidget ?
https://doc.qt.io/qt-5/qtablewidget.html#clearAre you just adding text to the items ? as
130 mb for 40 rows x 10 cols seems a bit much for text.Yes The same problem with ui->tableWidget->clear();
about the usage ..
the software uses 90 megabyte before using the tableWidget
and it reach 130 megabytes almost at 76 rows .. i tried it now ~~ -
@Proton-Phoenix
Hi
Well clear() should delete all items.Please be aware that some Os will free the mem for use for the app but it will not
show in Task Manager before the app is stopped.What platform/device are you testing on ?
-
@mrjj said in QTableWidget items Memory Leak Problem!:
@Proton-Phoenix
Hi
Well clear() should delete all items.Please be aware that some Os will free the mem for use for the app but it will not
show in Task Manager before the app is stopped.What platform/device are you testing on ?
all The items got deleted by clear();
but that not releasing any mem!
the same as setRowCount(0);
i am using Pc With windows 10
and Task Manager ! -
@Proton-Phoenix said in QTableWidget items Memory Leak Problem!:
Task Manager
This is not a good tool to look for memory leaks. On Linux one would use Valgrind for example. Not sure what you can use on Windows. Maybe Visual Studio provides tools for that?
-
i am not expert at visual studio but i will try to find similar to valgrind ...
does using any other free process monitor ?? show me the real stats??
or it's the same as task manager ! -
Any way Thank you so much for helping me i will keep trying until i find this mem leaks
-
@jsulm said in QTableWidget items Memory Leak Problem!:
@Proton-Phoenix said in QTableWidget items Memory Leak Problem!:
Task Manager
This is not a good tool to look for memory leaks. On Linux one would use Valgrind for example. Not sure what you can use on Windows. Maybe Visual Studio provides tools for that?
i found the memory leak bro
it was thisQSoundEffect effect; effect.setSource(QUrl::fromLocalFile("D:/**/**/**/**/barcode.wav")); effect.setLoopCount(1); effect.setVolume(0.40f); effect.play(); qDebug()<<effect.status(); // this the memory leak QEventLoop loop; loop.exec(); qDebug()<<effect.Error;
i used this to make a validation sound of adding values through barcode
it was keep using the ram more and more not QTableWidget at all
Thank you guys Really thank you -
Just a note about a non-Valgrind, windows-specific leak-checking method:
It has been a while since I have done any extensive work on a Microsoft platform, but in my recollection
crtdbg.h
can do many helpful diagnostic things, although it is sometimes tricky to get all the debug build settings configured in the way that will trigger the features you seek.