Skip to content

Conversation

marcusquinn
Copy link
Contributor

@marcusquinn marcusquinn commented Apr 16, 2025

Potential fix for #9 (comment)

Fix Memory Issues with Page Builders

Description

This PR addresses the memory exhaustion issues that occur when using page builders like Divi with WP Multisite WaaS. Users have reported fatal errors related to memory limits when editing pages with page builders while WP Multisite WaaS is active.

Changes Made

  1. Added a new Page_Builder_Detector class that can detect multiple page builders (Divi, Elementor, Beaver Builder, Gutenberg)
  2. Modified the Memory_Trap class to be more configurable with options to enable/disable it and set custom memory limits
  3. Implemented an adaptive memory management system that:
    • Detects the server's configured memory limit
    • Calculates an appropriate limit based on the server's settings (75% of the server limit)
    • Ensures a minimum threshold of 256MB to accommodate page builders
    • Adapts to different hosting environments automatically
  4. Created a safe JSON encode function to prevent memory issues with large data structures
  5. Added a generic compatibility layer that can be extended for other plugins

Benefits

  • Prevents memory exhaustion errors when using any page builder, not just Divi
  • Provides an adaptive approach to memory management that works across different hosting environments
  • Strikes a better balance between preventing unlimited memory consumption and providing enough resources
  • Improves overall stability when working with page builders
  • Future-proof design that can easily support new page builders

Technical Details

  • The compatibility class detects when any page builder editor is active and configures memory settings accordingly
  • Large data structures are automatically truncated when they exceed a certain size
  • Memory limits are set adaptively based on the server's configuration
  • Added hooks for developers to further customize the behavior

Testing

  1. Install and activate any supported page builder (Divi, Elementor, Beaver Builder, etc.)
  2. Edit a page with the page builder
  3. Verify that no memory exhaustion errors occur
  4. Check that the compatibility notice appears on page builder-related admin pages

Related Issues

Fixes #9 - Fatal error: wp-multisite-waas 2.3.4 appears to be consuming unlimited PHP Memory

@superdav42
Copy link
Collaborator

This is a lot of code to add for problems that don't seem to be related to our plugin. The unlimited memory setting would not trigger the error reported in the issue. Did you test the plugin combination and reproduce the error?

@marcusquinn
Copy link
Contributor Author

true, could always remove it later - just threw something up for @twicealive to test really - will see if we can make it more agnostic...

@marcusquinn marcusquinn changed the title Fix divi modules pro conflict Fix memory issues with page builders (agnostic solution) Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error: wp-multisite-waas 2.3.4 appears to be consuming unlimited PHP Memory
2 participants