Use SPI to compute the jetsam limit on iOS instead of hardcoding 840MB
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2018 20:35:05 +0000 (20:35 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Jul 2018 20:35:05 +0000 (20:35 +0000)
commitf68f263b4e79b1cb77c44e2689b214f2fae30b67
tree2c6e25861abd9e1b23f12bd714576a1725803f8a
parenta16fadc5569faa1696dfdcbdc966090c30da84b4
Use SPI to compute the jetsam limit on iOS instead of hardcoding 840MB
https://bugs.webkit.org/show_bug.cgi?id=188091
<rdar://problem/42647697>

Reviewed by Simon Fraser.

Source/bmalloc:

We want bmalloc to dynamically adapt to the jetsam limit of the process
it's running in. WTF::ramSize() is based off bmalloc's availableMemory,
so it will now reflect the result of the real jetsam limit when we can
read it.

Reading the jetsam limit requires an entitlement, so this patch opts in
the WebContent/Storage/Network processes. We fall back to 840MB (the
old hard coded value) when the SPI call fails (e.g, when we're in a
process without the proper entitlement).

* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/AvailableMemory.cpp:
(bmalloc::jetsamLimit):
(bmalloc::computeAvailableMemory):
* bmalloc/darwin/MemoryStatusSPI.h: Added.

Source/WebKit:

Give the Network/Storage/WebContent process the com.apple.private.memorystatus
entitlement. This allows them to read the process jetsam limit.

* Configurations/Databases-iOS.entitlements:
* Configurations/Network-iOS.entitlements:
* Configurations/WebContent-iOS.entitlements:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Databases-iOS.entitlements
Source/WebKit/Configurations/Network-iOS.entitlements
Source/WebKit/Configurations/WebContent-iOS.entitlements
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/AvailableMemory.cpp
Source/bmalloc/bmalloc/darwin/MemoryStatusSPI.h [new file with mode: 0644]