Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP's garbage collection mechanism handle recursive reference issue?

In perl this will cause recursive reference :

$a = \$a;

And $a's reference count will never come to 0 again...

Does PHP has similar issue?

If not,how does PHP gc handles it?

like image 368
Je Rog Avatar asked Mar 11 '26 05:03

Je Rog


1 Answers

As of PHP 5.3.0, PHP's Garbage collector can and will collect graphs of objects that contain cycles.

See PHP: Collecting Cycles

like image 72
user703016 Avatar answered Mar 12 '26 18:03

user703016