PHP compilation principle:
ze (zend engine) calls the lexical analyzer to remove spaces from the PHP code, split it into tokens after comments, and ze calls syntax analysis The processor then processes the token to form opcode, which exists in the form of op array, and finally executes op array to output the result.
When a PHP thread ends, all memory space currently occupied will be destroyed. So if this thread does not end, how to reclaim the memory?
refcount: Reference technology device, which can be understood as the number of pointers pointing to the container.
is_ref: Whether it is referenced (can only be 0 or 1)
Assignment process:
Copy after login
Reference process:
Copy after login
If there are more If you unset one reference, will is_ref be set to zero? Then won’t a bug appear? Variable containers are still references. So let's take a look:
Copy after login
Can unset and assignment null recycle variables? Many people mistakenly believe that these two can recycle variable space. In fact, they are wrong. null only reduces the space occupied by variables. From a recycling perspective, the container still exists.
Copy after login
Recommended:PHP video tutorial
The above is the detailed content of Introduction to PHP garbage collection mechanism (gc). For more information, please follow other related articles on the PHP Chinese website!