[webkit-reviews] review denied: [Bug 28876] [Qt] reduce peak memory consumption of text decoding. : [Attachment 38868] Cut big input buffer to small buffers to reduce peak memory during decoding.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 3 02:06:31 PDT 2009


Ariya Hidayat <ariya.hidayat at trolltech.com> has denied Yongjun Zhang
<yongjun.zhang at nokia.com>'s request for review:
Bug 28876: [Qt] reduce peak memory consumption of text decoding.
https://bugs.webkit.org/show_bug.cgi?id=28876

Attachment 38868: Cut big input buffer to small buffers to reduce peak memory
during decoding.
https://bugs.webkit.org/attachment.cgi?id=38868&action=review

------- Additional Comments from Ariya Hidayat <ariya.hidayat at trolltech.com>

> +    // We chop input buffer to smaller buffers to avoid excessive memory
consumption
> +    // when the input buffer is big.  This helps reduce peak memory
consumption in
> +    // mobile devices where system RAM is limited.
> +    static const int kInputChunkSize = 32 * 1024;

In Qt we don't use Hungarian notation :) You can safely drop "k" prefix there.

> +    const char* buf = bytes;
> +    const char* end = buf + length;
> +    String unicode;
> +
> +    while (buf < end) {
> +	   int size = end - buf;
> +	   size = qMin(size, kInputChunkSize);
> +	   QString decoded = m_codec->toUnicode(buf, size, &m_state);
> +	   unicode.append(decoded);
> +	   buf += size;
> +    }

While this reduced the peak heap, my concern is the speed. Because we append a
small block every time, String needs to grow and reallocate.
Also QTextCode constantly allocates and deallocates 32KB QString.

Can you use Valgrind to see the difference in the memory consumption?

Can we perhaps specify the inputChunkSize, say a small value for Symbian but a
larger one for other platforms?

r- until these issues are addressed.


More information about the webkit-reviews mailing list