[Development] QtCore missing check for memory allocation

Thiago Macieira thiago.macieira at intel.com
Thu Feb 26 19:35:43 CET 2015


On Thursday 26 February 2015 19:22:56 Konstantin Tokarev wrote:
> When using such a large library as Qt is quite hard to get along with
> disabled overcommit on embedded device (because you need to keep your
> application's VmSize under than size of physical memory).

That's not necessary.

Let me take an example:

$ ~/src/owntools/rssanalyse/rssanalyse.pl `pidof qtcreator`
Total mapped memory:     5445164 kB
    of which is padding: 1988700 kB
   of which swapped out: 132204 kB
  of which likely stack: 32908 kB mapped, 140 kB resident (80 kB main, 60 kB 
aux threads)
  of which are resident: 732556 kB, 722644 kB proportionally shared
        total anonymous: 704784 kB (96.2%)
                 Shared: 17628 kB total (2.4% of RSS)
              Breakdown: 2596 kB clean (14.7%), 15032 kB dirty (85.3%)
                         2540 kB code (14.4%), 56 kB RO data (0.3%), 15032 kB 
RW data (85.3%)
                         0 kB heap (0.0%), 0 kB stack (0.0%), 0 kB other 
(0.0%)
                Private: 714928 kB total (97.6% of RSS)
              Breakdown: 27796 kB clean (3.9%), 687132 kB dirty (96.1%)
                         9576 kB code (1.3%), 6324 kB RO data (0.9%), 2080 kB 
RW data (0.3%)
                         696344 kB heap (97.4%), 140 kB stack (0.0%), 464 kB 
other (0.1%)

Qt Creator's VSZ is 5.3 GB but it has nearly 2 GB of that used for padding 
only (memory regions that with no read, write or execute permissions). That 
leaves 3.3 GB of virtual memory that is either readable, writable or 
executable.

Even then, the program's actual, physical memory usage is 715 MB. Even if you 
add the amount of memory swapped out (128 MB), that still leaves 2.5 GB of VSZ 
that isn t backed by main RAM. A quick sampling of the process's smaps shows 
there are large chunks of mapped memory that have hardly been used. I expect 
many of those come from threading -- whenever you start a thread, glibc maps a 
64 MB chunk of heap zone and 8 MB of stack, but only a few kB of those are 
ever used.

The RSS is the current "working set size" for Qt Creator. That is, it runs fine 
with this amount of RAM. It may run with less RAM, if you subtract the clean 
portions of the RSS (29 MB) or if you swap out the dirty portions.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list