Skip to content

A cycle that runs through an array of objects stored as a Manticore\Ds\Map value is not collected by gc_collect_cycles(). #124

Open

Description

@blacktrs

Summary

A cycle that runs through an array of objects stored as a Manticore\Ds\Map value is not collected by gc_collect_cycles().

Repro

<?php
use Manticore\Ds\Map;
final class A { public ?Map $m = null; public string $pad; public function __construct() { $this->pad = str_repeat('x', 16384); } }
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 2000; $i++) {
    $a = new A();
    $m = new Map();
    $a->m = $m;
    $m->set('list', [$a]);
    unset($a, $m);
    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 43 MB)

Tracking

Known-bug repro: tests/aot/repro/leak/cc_map_value_array_cycle_not_collected.php — bash tests/aot/xfail.sh -k cc_map_value_array_cycle_not_collected 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
    needs-design
    area:runtime
    on Oct 7, 2026
  2. blacktrs commented on Oct 13, 2026

    @blacktrs
    ContributorAuthor

    Scope: collector extension. The cycle collector walks only object properties, never array buffers. A plain $a->kids = [$a] cycle leaks the same way (confirmed with a probe), so the Map-value case is one instance. Fix: teach the collector to walk array buffers (elements are cells/objects by element repr hint), including Ds Map value arrays. Found in batch E; skipped. Repro: tests/aot/repro/leak/cc_map_value_array_cycle_not_collected.php.

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

    area:runtimebugleakneeds-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions