Skip to content

Runtime: gc_collect_cycles() — run cyclic GC (Zend GC parity) #3113

Description

@PurHur

Category

runtime

Problem

gc_collect_cycles() is not available. Zend’s refcount + cycle collector frees unreachable object graphs; long-lived apps and tests call it explicitly. This compiler exposes a WeakReference subset (#1366) without a public sweep entry point.

php-src reference

  • Zend/zend_gc.c — gc_collect_cycles(), zend_gc_collect_cycles()
  • ext/standard/info.c — PHP_FUNCTION(gc_collect_cycles)

Repro (today)

<?php
class Node { public ?Node $next = null; }
$a = new Node();
$b = new Node();
$a->next = $b;
$b->next = $a;
unset($a, $b);
echo gc_collect_cycles();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'

Zend PHP: integer ≥ 1 (cycles collected)
This compiler: Call to undefined function gc_collect_cycles()

Scope

  • ext/standard/gc_collect_cycles.php + Module.php
  • VM: hook into object refcount / cycle buffer (implement real collector or document v1 stub with follow-up)
  • test/compliance/cases/runtime/gc_collect_cycles.phpt

Done when

  • Repro runs without undefined function
  • Return value matches Zend on a simple 2-node cycle after unset
  • ./script/ci-fast.sh --filter gc_collect_cycles green

Links

Activity

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:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions