PATCH/RFC Pool allocations of QStringData objects..
Maks Orlovich
kde-optimize@mail.kde.org
Sat, 18 Jan 2003 00:20:07 -0500
> This number of course, deserves a pause. This means, if it's correct, that
> we have created 100,000 QStringData and hence QString objects during the
> startup! And subtracting frees from allocs, we have some 26,784 strings in
> memory!
The vast majority of the used memory seems to be the history, which I guess is
OK, considering that it's information we actually do need. However, the
protocols reappear an awful lot -- logging the strings getting freed (yeah,
that misses non-freed ones, I know), I can do:
cat ../log|grep http$ |wc -l
3127
cat ../log|grep file$ |wc -l
805
cat ../log|grep https$ |wc -l
167
i.e. nearly 4000 strings are just copies of "http", "https" and "file"
protocol names. I wonder whether there is a way to get rid of that
efficiently.. (Some sort of a global protocol name dictionary?)
For the temporary ones, about 12,000 are accounted for by QTextStream creating
temporary 1 character strings when doing readLine (mostly since it's using
ts_getchar, which in turn uses ts_getbuf, the latter of which is not
efficient for per-char reads at all); this is what QSettings uses. The likely
fix is in figuring out what's wrong with the #if 0'd fast path in
QTextStream::readLine ;-)
Anybody want the patch that makes QStringData dump its string contents when
it's getting deleted?
-Maks