[iOS] Drop buffered data in paused media elements on memory pressure.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Jun 2015 22:16:04 +0000 (22:16 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Jun 2015 22:16:04 +0000 (22:16 +0000)
commitd95e516e94ce7d6002a0838ac2171629247212d3
tree8592e4c0026dfcb90e39addac03f134a7c00c794
parentc37a0aa12f083ffd99d5ef112b4d5aba79581b90
[iOS] Drop buffered data in paused media elements on memory pressure.
<https://webkit.org/b/146369>
<rdar://problem/20366883>

Reviewed by Eric Carlson.

To avoid getting crushed under mediaserverd memory growth when viewing
a page with multiple media elements, add a step to the memory pressure
handler that drops buffered data from all media elements that are
not currently playing.

On a test page with a bunch of embedded YouTube videos, this pass frees
up ~4MB per paused video when the system memory pressure hits.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::allMediaElements):
(WebCore::HTMLMediaElement::HTMLMediaElement):
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::purgeBufferedDataIfPossible):
* html/HTMLMediaElement.h:
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseCriticalMemory):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186054 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/MemoryPressureHandler.cpp