[Webkit-unassigned] [Bug 69913] Use realloc() to expand/shrink StringBuilder buffer

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jan 30 12:35:10 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=69913





--- Comment #12 from Xianzhu Wang <wangxianzhu at chromium.org>  2012-01-30 12:35:10 PST ---
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > The more frequently you see realloc returns the same pointer, the more memory waste is happening.
> > 
> > Could you explain more about the above sentence?
> 
> When realloc returns same pointer, it means the new size is smaller than the old or original size, and the memory allocator can reuse the original memory block. Usually (there are specials), the memory allocator doesn't free the rest of the memory block that is not used any more. For eample, the original buffer in StringBuilder is 2K, but the length is 512 bytes. When the string build job finishes, StringBuilder::toString() calls shrinkToFit(), which is supposed to allocate a new 512-byte buffer and free the 2K buffer. But with the patch, realloc can still use the 2K buffer which leaves 1.5K waste.

Could you provide link of memory allocator which works like this?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list