Title: [173080] trunk/Source/WebCore
- Revision
- 173080
- Author
- psola...@apple.com
- Date
- 2014-08-28 14:08:26 -0700 (Thu, 28 Aug 2014)
Log Message
WebContent hangs under SharedBuffer::duplicateDataBufferIfNecessary() while browsing some websites
https://bugs.webkit.org/show_bug.cgi?id=136347
<rdar://problem/18073745>
Reviewed by Andreas Kling.
When passing data to ImageIO, we create a copy if we have to reallocate the buffer. We would
set the size of the new buffer to be the size of the SharedBuffer data. This causes memory
churn since we would create a new buffer for every data chunk we get. Fix this by at least
doubling the capacity of the buffer when we duplicate it.
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (173079 => 173080)
--- trunk/Source/WebCore/ChangeLog 2014-08-28 21:01:25 UTC (rev 173079)
+++ trunk/Source/WebCore/ChangeLog 2014-08-28 21:08:26 UTC (rev 173080)
@@ -1,3 +1,19 @@
+2014-08-28 Pratik Solanki <psola...@apple.com>
+
+ WebContent hangs under SharedBuffer::duplicateDataBufferIfNecessary() while browsing some websites
+ https://bugs.webkit.org/show_bug.cgi?id=136347
+ <rdar://problem/18073745>
+
+ Reviewed by Andreas Kling.
+
+ When passing data to ImageIO, we create a copy if we have to reallocate the buffer. We would
+ set the size of the new buffer to be the size of the SharedBuffer data. This causes memory
+ churn since we would create a new buffer for every data chunk we get. Fix this by at least
+ doubling the capacity of the buffer when we duplicate it.
+
+ * platform/SharedBuffer.cpp:
+ (WebCore::SharedBuffer::duplicateDataBufferIfNecessary):
+
2014-08-28 Dan Bernstein <m...@apple.com>
iOS build fix.
Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (173079 => 173080)
--- trunk/Source/WebCore/platform/SharedBuffer.cpp 2014-08-28 21:01:25 UTC (rev 173079)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp 2014-08-28 21:08:26 UTC (rev 173080)
@@ -27,6 +27,7 @@
#include "config.h"
#include "SharedBuffer.h"
+#include <algorithm>
#include <wtf/PassOwnPtr.h>
#include <wtf/unicode/UTF8.h>
@@ -351,11 +352,13 @@
void SharedBuffer::duplicateDataBufferIfNecessary() const
{
- if (m_buffer->hasOneRef() || m_size <= m_buffer->data.capacity())
+ size_t currentCapacity = m_buffer->data.capacity();
+ if (m_buffer->hasOneRef() || m_size <= currentCapacity)
return;
+ size_t newCapacity = std::max(static_cast<size_t>(m_size), currentCapacity * 2);
RefPtr<DataBuffer> newBuffer = adoptRef(new DataBuffer);
- newBuffer->data.reserveInitialCapacity(m_size);
+ newBuffer->data.reserveInitialCapacity(newCapacity);
newBuffer->data = ""
m_buffer = newBuffer.release();
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes