In:

https://github.com/php/php-langspec/blob/master/spec/04-basic-concepts.md#reclamation-and-automatic-memory-management

> Despite the use of the term refcount, conforming implementations are not
required to use a reference counting-based implementation for automatic
memory management.

Is this statement correct? If I understand correctly many PHP projects
depend on the deterministic firing of `__destruct()` function to cleanup
SQL transactions or connections and so forth.

HHVM elaborates on this:

> Eliminating destructors. Deterministic object destruction is the reason
why nonscalar PHP values require precise reference counting. This
requirement has long been, and continues to be, a sizable performance
bottleneck in our optimized JIT-compiled code. Using garbage collection
instead could unlock measurable performance improvements, and the behavior
of destructors could be closely imitated by a combination of try/finally
and other new language constructs.

(from http://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html )

I'm curious about the answer here. Is ref counting necessary for all PHP
implementations like HHVM claims?

Thanks,

Sidharth

Reply via email to