Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Memory Exhaustion in ConvertSwooleRequestToIlluminateRequest by Cleaning Up Unused Variables #953

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

jbidad
Copy link
Contributor

@jbidad jbidad commented Sep 24, 2024

This pull request addresses the memory exhaustion issue occurring in the ConvertSwooleRequestToIlluminateRequest.php file by explicitly unsetting unused variables. The issue arises during the request-to-response cycle in Laravel Octane, where excessive memory consumption leads to fatal errors.

Changes Made:

  • Added unset() for the additional variable $context to ensure it is cleared from memory along with other variables ($gateway, $sandbox, $request, $response, $octaneResponse, and $output).
    unset($gateway, $sandbox, $context, $request, $response, $octaneResponse, $output);

Issue Fixed:

This change prevents memory leaks or excessive memory retention, especially during high-volume or large request processing in Laravel Octane with the Swoole server. This fix resolves the memory exhaustion error reported in issue #952.

Steps to Reproduce:

  1. Configure the php.ini size limitations properly (e.g., post_max_size, upload_max_filesize, memory_limit).
  2. Adjust Swoole settings by configuring socket_buffer_size and package_max_length in config/octane.php.
  3. Run Laravel Octane with the Swoole driver.
  4. Process complex requests (e.g., file uploads or large payloads).
  5. The server previously failed due to memory exhaustion, which this fix addresses by unsetting additional variables during request conversion.

This pull request ensures proper memory management and improves the stability of applications running under heavy workloads with Laravel Octane.

@taylorotwell taylorotwell merged commit 3726a71 into laravel:2.x Sep 24, 2024
14 checks passed
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.

2 participants