PHP is a managed memory environment, meaning it will automatically allocate and deallocate memory space as necessary without any specific thought necessarily being given by the user.
Likewise, Python is also a managed memory environment. The language environment will manage memory as necessary on its own, and requires no explicit programmatic consideration for day-to-day code.
PHP uses the Zend Memory Manager to act as a go-between for PHP's requests for memory space and the traditional C libraries for asking the operating system for resources.
Python uses the Python Memory Manager to act as a go-between for the language and the OS-level memory allocation layer.
Yes, and is directly accessible at the module level.
Yes. PHP stores the reference count internally in an refcount
variable inside a zval
container attached to all variables.
Yes, the memory manager will automatically return an objects memory space to the OS-level if its reference count reaches zero.