Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PHP's garbage collector is ARC, unlike any other dynamic language that I know of.

ARC is more performant but can introduce memory leaks via circular references, which is probably not a big problem for short-lived scripts anyway.



Python uses ARC plus a tracing GC for dealing with cycles, same as PHP: https://devguide.python.org/garbage_collector/

Perl uses ARC with no tracing GC, so you have to handle cycles yourself: https://www.perlmonks.org/?node_id=1173079

TCL uses ARC, and apparently doesn't need a tracing GC because it is impossible to create cycles in it: https://wiki.tcl-lang.org/page/Garbage+collection


ARC is not more performant, it's more deterministic. "regular" GCs have better throughput. RC in general also handles other resources (like files) a bit better than GC.


I'm not sure if you did not read what I quoted, or I misunderstand something.

Yes, PHP has reference counting, but it also has specific process that kicks in to clean up circular references.


Sounds optimal for PHP where 99% of scripts are short lived.


Which is perfect for a HTTP request.


How is it more performant? If you have multiple threads than you will get serious atomic operation or other synchronization overhead.


PHP is share-nothing architecture. Nobody really uses threads in mainline PHP.

Whole class of problems around multi-threading, mutexes, dead locks etc. are really foreign to PHP developers.


Yeah, I should have mentioned that in the general case RC is not more performant (otherwise threaded managed languages would use it).


PHP has a GC since 2009 (version 5.3). Its goal is precisely to collect reference cycles.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: