On 4/14/19, Sean Conner <sean@conman.org> wrote:
> What's wrong with __gc ?
please read
http://sealedabstract.com/rants/why-mobile-web-apps-are-slow/
Many of the points in that article are still valid, but mobile platforms are no longer as resource constrained as they were in 2013, and a well-designed GC may be faster than a reference counting implementation, especially one in a multithreaded environment.
A thread safe reference counting implementations is not cheap:
C++ std:shared_ptr<> reference counting for instance introduces lots of overhead because the reference count is adjusted using thread safe (atomic) operations, and those operations are slow. I managed to double the speed of a single threaded program by writing a shared_ptr variant that was not thread safe (and yes, I used move construction and move assignment wherever feasible to avoid reference count adjustments).
When I added thread safety back into my implementation it became just as slow as std::shared_ptr<>.
Gé
--