We're using PHP to access our custom C++ objects. Some of those C++ objects are fairly large so we'd like to keep them around until the last PHP object that references them is destroyed.
We've been trying to use the zend callback functions add_ref and del_ref but it seems that PHP can create copies of objects so multiple PHP objects can reference each of our C++ objects.
Because of that, our current approach results in our C++ objects being destroyed when other PHP object(s) still reference them.
Any ideas how to overcome this?