Title: [90592] trunk/Source/WebCore
- Revision
- 90592
- Author
- commit-qu...@webkit.org
- Date
- 2011-07-07 15:09:36 -0700 (Thu, 07 Jul 2011)
Log Message
Patch by James Robinson <jam...@chromium.org> on 2011-07-07
Reviewed by Kenneth Russell.
Use v8::AdjustAmountOfExternalAllocatedMemory for ArrayBuffers
https://bugs.webkit.org/show_bug.cgi?id=42912
This calls v8's AdjustAmountOfExternalAllocatedMemory when ArrayBuffers are allocated/deallocated so that V8's
garbage collection heuristics can account for the memory held by these objects. On the new test page, this
reduces the peak memory use from 5BG+ (or a crash in 32-bit systems) to <300MB.
Test: WebCore/manual-tests/array-buffer-memory.html
* html/canvas/ArrayBuffer.cpp:
(WebCore::ArrayBuffer::~ArrayBuffer):
(WebCore::ArrayBuffer::tryAllocate):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (90591 => 90592)
--- trunk/Source/WebCore/ChangeLog 2011-07-07 21:37:26 UTC (rev 90591)
+++ trunk/Source/WebCore/ChangeLog 2011-07-07 22:09:36 UTC (rev 90592)
@@ -1,3 +1,20 @@
+2011-07-07 James Robinson <jam...@chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ Use v8::AdjustAmountOfExternalAllocatedMemory for ArrayBuffers
+ https://bugs.webkit.org/show_bug.cgi?id=42912
+
+ This calls v8's AdjustAmountOfExternalAllocatedMemory when ArrayBuffers are allocated/deallocated so that V8's
+ garbage collection heuristics can account for the memory held by these objects. On the new test page, this
+ reduces the peak memory use from 5BG+ (or a crash in 32-bit systems) to <300MB.
+
+ Test: WebCore/manual-tests/array-buffer-memory.html
+
+ * html/canvas/ArrayBuffer.cpp:
+ (WebCore::ArrayBuffer::~ArrayBuffer):
+ (WebCore::ArrayBuffer::tryAllocate):
+
2011-07-07 Ryosuke Niwa <rn...@webkit.org>
Move all code related to cachedSelection to HTMLTextFormControlElement
Modified: trunk/Source/WebCore/html/canvas/ArrayBuffer.cpp (90591 => 90592)
--- trunk/Source/WebCore/html/canvas/ArrayBuffer.cpp 2011-07-07 21:37:26 UTC (rev 90591)
+++ trunk/Source/WebCore/html/canvas/ArrayBuffer.cpp 2011-07-07 22:09:36 UTC (rev 90592)
@@ -26,6 +26,10 @@
#include "config.h"
#include "ArrayBuffer.h"
+#if USE(V8)
+#include "V8Binding.h"
+#endif
+
#include <wtf/RefPtr.h>
namespace WebCore {
@@ -76,6 +80,9 @@
ArrayBuffer::~ArrayBuffer()
{
+#if USE(V8)
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_sizeInBytes);
+#endif
WTF::fastFree(m_data);
}
@@ -91,8 +98,12 @@
if (totalSize / numElements != elementByteSize)
return 0;
}
- if (WTF::tryFastCalloc(numElements, elementByteSize).getValue(result))
+ if (WTF::tryFastCalloc(numElements, elementByteSize).getValue(result)) {
+#if USE(V8)
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(numElements * elementByteSize);
+#endif
return result;
+ }
return 0;
}
Added: trunk/Source/WebCore/manual-tests/array-buffer-memory.html (0 => 90592)
--- trunk/Source/WebCore/manual-tests/array-buffer-memory.html (rev 0)
+++ trunk/Source/WebCore/manual-tests/array-buffer-memory.html 2011-07-07 22:09:36 UTC (rev 90592)
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>ArrayBuffer memory test</title>
+</head>
+<body>
+Test creating many ArrayBuffers. The page should fully load without crashing and without using more than ~300mb of ram.
+<script>
+
+function allocateLargeBuffer() {
+ var arrayBuffer = new ArrayBuffer(64*1024*1024);
+}
+
+for (var i=0; i<96; ++i)
+ allocateLargeBuffer();
+</script>
+
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes