Skip to content

Instantly share code, notes, and snippets.

@patrickallaert
Forked from anonymous/result.txt
Created July 2, 2013 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickallaert/5908022 to your computer and use it in GitHub Desktop.
Save patrickallaert/5908022 to your computer and use it in GitHub Desktop.
$ php test.php
Array
(
[a] => 1
[b] => 1
)
Array
(
[a] => 1
[b] => 1
)
Array
(
[a] => 1
[b] => 1
)
2 cyclic objects freed
Array
(
)
<?php
class a {}
class b {}
$a = new a;
$b = new b;
print_r(get_objects_count());
// Create circular deps
$a->b = $b;
$b->a = $a;
print_r(get_objects_count());
// Destroying objects
unset($a, $b);
print_r(get_objects_count());
// Forces collection of any existing garbage cycles
echo gc_collect_cycles(), " cyclic objects freed\n";
print_r(get_objects_count());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment