Skip to content

[PHP web] Lower initial memory allocation for PHP instances#3192

Merged
adamziel merged 1 commit intotrunkfrom
lower-initial-memory-usage
Jan 27, 2026
Merged

[PHP web] Lower initial memory allocation for PHP instances#3192
adamziel merged 1 commit intotrunkfrom
lower-initial-memory-usage

Conversation

@adamziel
Copy link
Collaborator

@adamziel adamziel commented Jan 27, 2026

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

  • CI
  • Manually test in Safari on iOS and Mac, confirm the memory usage is reliably lower

@adamziel adamziel merged commit 2e3eb97 into trunk Jan 27, 2026
35 checks passed
@adamziel adamziel deleted the lower-initial-memory-usage branch January 27, 2026 00:30
@adamziel adamziel changed the title Lower initial memory allocation for PHP instances [PHP web] Lower initial memory allocation for PHP instances Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant