Skip to content

A typed array (Int32Array) held by an object in a cycle leaks its buffer when gc_collect_cycles() collects the cycle. #123

Closed

Description

@blacktrs

Summary

A typed array (Int32Array) held by an object in a cycle leaks its buffer when gc_collect_cycles() collects the cycle.

Repro

<?php
use Manticore\Ds\Int32Array;
final class Holder { public ?Holder $self = null; public Int32Array $buf; public function __construct() { $this->buf = new Int32Array(4096); } }
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 2000; $i++) {
    $h = new Holder();
    $h->self = $h;
    unset($h);
    gc_collect_cycles();
}
$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 46bda0f8, Darwin arm64)

LEAK
(stderr: grew 41 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/cc_cycle_typed_array_buffer_leaks.php — bash tests/aot/xfail.sh -k cc_cycle_typed_array_buffer_leaks 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 7, 2026
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