Skip to content

rotatePHPRuntime: track occupied memory, rotate the PHP runtime automatically when necessary #998

Open

Description

@adamziel

#990 introduced a rotatePHPRuntime function that swaps the internal PHP runtime for a fresh one after a certain number of requests are handled. This is necessary because PHP has a memory leak and exhaust the HEAP space eventually.

Ideally the rotation logic would be based on the amount of free, unfragmented memory.

The challenge there is to find a fast method of keeping track of that – even a naive approach of calculating the null bytes takes a few blocking seconds.

cc @sejas

Activity

  1. dmsnell commented on Feb 5, 2024

    @dmsnell
    Member

    Ideally the rotation logic would be based on the amount of free, unfragmented memory.

    I'm not sure that's necessary or ideal. It seems like the highest-allocated address would serve as a reasonable proxy for memory use, particularly of growing memory use.

    And this is because even if we have purely fragmented memory, if we aren't extending the allocated range then we're not growing overall use. On the other hand, memory could be entirely unfragmented and we could still fail to acquire a span large enough for a chunk being requested.

    My original thought was to track the highest allocated address and after a given threshold, swap out the runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions