Skip to content

Indexing a temporary array literal of new objects never releases the objects. #591

Closed

Description

@blacktrs

Summary

Indexing a temporary array literal of new objects never releases the objects.

Repro

<?php
class A { public string $p = 'x'; }
class B { public string $p = 'y'; }
function pick(int $i): object { return [new A, new B][$i]; }
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 400000; $i++) { $o = pick($i % 2); }
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 8 ? "flat\n" : "leak\n";

Expected (php)

flat

Actual (manticore ccce2f0f, Darwin arm64)

leak
(stderr: grew 71 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/array_literal_index_objects.php — bash tests/aot/xfail.sh -k array_literal_index_objects 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 Nov 7, 2026
  2. added a commit that references this issue on Nov 9, 2026
    a48d46e
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