4 ms·
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
by mojuba 5y ago
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.
- nicoburns 5y agoSounds optimal for PHP where 99% of scripts are short lived.
- JiNCMG 5y agoWhich is perfect for a HTTP request.
- Isinlor 5y agoI'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.
- kaba0 5y agoHow is it more performant? If you have multiple threads than you will get serious atomic operation or other synchronization overhead.
- Isinlor 5y agoPHP 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.
- kaba0 5y agoYeah, I should have mentioned that in the general case RC is not more performant (otherwise threaded managed languages would use it).
- housecarpenter 5y agoPython uses ARC plus a tracing GC for dealing with cycles, same as PHP: https://devguide.python.org/garbage_collector/ 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 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 https://wiki.tcl-lang.org/page/Garbage+collection
- Zababa 5y agoARC 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.
- fooyc 5y agoPHP has a GC since 2009 (version 5.3). Its goal is precisely to collect reference cycles.