Possible memory leak in QVariant::toString().split()
Unsolved
General and Desktop
-
QVariantMap map; map["key"]=QString("val1,val2,val3,val4,val5,val6,val7,val8,val9,val0"); // memory increase in loop and not release for (int i =0; i < 100000; i++) { QStringList list = map["key"].toString().split(","); QStringList sameList = (*static_cast<QString*>(map["key"].constData())).split(","); //qDebug() << i << list.size() << sameList.size(); }
Qt 6.5.3 build static from source cross by arm-linux-gnueabihf-gcc-9.5, execute with warning:
Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8." -
Do not concern yourself with (very unlikely) Qt memory leak issues when you do abominations like this:
(*static_cast<QString*>(map["key"].constData())).split(",");
-
How do you know that there is a leak? Use a proper profiler.
-
@Christian-Ehrlicher I wraped functions free & malloc, as: __wrap_malloc & __wrap_free. Then I start QProcess with ssh command to host to get backtrace via gdb-multiarch in __wrap_malloc to search code location where allocated mem not released.
-
Use a proper profiler for instead some self made stuff. There is no memory leak.
-
@Christian-Ehrlicher Does exist a proper profiler for embedded arm?