Skip to content

Leak: a fresh value passed to Generator::send() is never released #22

Closed

Description

@blacktrs

Summary

Leak: a fresh value passed to Generator::send() is never released.

Repro

<?php
function g(): \Generator { while (true) { $v = yield; } }
function mk(int $i): string { return str_repeat('s', 300) . $i; }
$m0 = memory_get_peak_usage();
$g = g();
$g->current();
for ($i = 0; $i < 100000; $i++) { $g->send(mk($i)); }
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 8 ? "flat\n" : "LEAK\n";

The repro measures its own peak RSS (memory_get_peak_usage()) around the loop and prints flat when it grew by less than 8 MB.

Expected (php 8.5)

flat

Actual (manticore 10affa68, macOS arm64)

LEAK
(stderr: grew 37 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/generator_send.php — bash tests/aot/xfail.sh -k generator_send reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    leak
    on Oct 5, 2026
  2. added a commit that references this issue on Oct 6, 2026
    2133738
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugleak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions