I uses 64 linux with fresh install of qt 5.1.0.
I take example application qtbase/examples/widgets/widgets/lineedits and run, let’s call it qt5_lineedit, also I take the similar app from qt4 sources build it with qt4 library and run.
And in htop I see that, there are two qt5_lineedit (I run only one, so it used 2 threads) and memory usage: VIRT 223M RES 18268.
While for qt4_lineedit exists only one process and it eats: VIRT 126M RES 15848.
So,
- Why qt5 uses two threads by default?
- Why so much diffrence in virtual memory size?
Update.
In spite of qt5_lineedit uses 2 pids, they are not processes, but threads. So info about qt4_lineedit looks like:
VmPeak: 130936 kB VmSize: 130932 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 17140 kB VmRSS: 17140 kB VmData: 4524 kB VmStk: 136 kB VmExe: 28 kB VmLib: 48232 kB VmPTE: 220 kB VmSwap: 0 kB Threads: 1
The info about qt5_lineedit looks like:
VmPeak: 278020 kB VmSize: 228584 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 18268 kB VmRSS: 18268 kB VmData: 77468 kB VmStk: 136 kB VmExe: 28 kB VmLib: 50056 kB VmPTE: 288 kB VmSwap: 0 kB Threads: 2
Advertisement
Answer
The second thread (not process) comes from the XCB QPA plugin, which spawns a thread to poll for XCB events. (I don’t know if that’s for working around XCB bugs, XCB API or what.)
In general, you can’t compare two processes memory usage by looking at VM summaries. You need to properly analyze the processes’ memory maps (/proc/pid/maps
), and figure out how much memory got allocated, and where, and if it’s getting shared amongst other processes or it’s real per-process usage. Moreover, if you see a difference in dynamically-allocated memory, you need further analysis about the per-process usage by using a heap profiler (such as valgrind’s massif).
Who said that profiling memory usage was an easy task? 🙂