[PHP web] Lower initial memory allocation for PHP instances#3192
Merged
[PHP web] Lower initial memory allocation for PHP instances#3192
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduces the initial memory allocation from 1024MB to 256MB per PHP instance. The PHP runtime still has room to grow when needed through Emscripten's memory growth mechanism, but starts with a much smaller footprint. Testing shows this reduces peak memory usage by approximately 40% and idle memory consumption by 3x. In Safari Technology Preview, peak usage dropped from over 2GB to around 1.26GB.
Rationale
WordPress Playground has been allocating 1GB of memory upfront for each PHP instance. When the Playground boots multiple instances to handle concurrent operations during startup, this creates memory spikes exceeding 3GB. On memory-constrained devices like older iPhones or budget Android phones, these spikes can cause crashes or severe performance degradation.
The lower memory floor makes WordPress Playground more accessible across a wider range of devices while maintaining full functionality. PHP instances can still allocate additional memory as WordPress runs more complex operations, but typical workflows can now stay within the reduced limits.
Test plan