What is the garbage collection mechanism of PHP?
Title...
Is the online search Tencent pen question ...
------Solution--------------------
Only know the garbage collection mechanism of the session
------Solution--------------------
Do not understand, help top, look forward to master.
------Solution--------------------
Other manuals say that the main resource will be the postpartum garbage problem, but after the PHP4 has a count function, which fruit resources are not occupied, will automatically release
------Solution--------------------
In PHP, when there are no variables pointing to this object, the object becomes garbage. PHP will destroy it in memory, which is the GC garbage disposal mechanism of PHP to prevent memory overflow.
When a PHP thread ends, all memory space currently occupied is destroyed, and all objects in the current program are destroyed at the same time. GC processes are typically run with each session. The GC is designed to automatically destroy deleted files after the session file expires.
------Solution--------------------
Performing these functions can also play a role in recycling
__destruct/unset/mysql_close
------Solution--------------------
PHP's garbage collection mechanism does not need to be considered by programmers,
As long as the resource of the use of the timely closure, the use of resources large variables in a timely manner unset can be.
------Solution--------------------
PHP has a clear GC processing time setting for the session
Session.gc_maxlifetime
------Solution--------------------
Personally feel that each request is a process.
------Solution--------------------
I'll leave a trace.
------Solution--------------------
------Solution--------------------
------Solution--------------------
Garbage disposal for memory consumption?
First, PHP as the scripting language is the end of the page to release the memory of the variable.
If there is garbage, it is the whole program in the framework of the use of multiple calls to the same file, etc. caused by non-single-piece mode.
So when it comes out, it is necessary to use the _once reference, using a single-piece mode when declaring the class. There are simplified logic and so on.
And if you want PHP itself to manage memory, garbage management. Oh. As if PHP could not be done, for the destructor, Andi in his book is very clear. Optional, not set No.
and the memory management of things are generally the desktop program to consider more. PHP is not going to engage in a memory management thing, eh, beyond.
------Solution--------------------
Learn
------Solution--------------------
Hehe ~ ~, learning to pull!
------Solution--------------------
Do not understand, read the JavaScript garbage collection mechanism, PHP really did not notice!
------Solution--------------------
Remember that the book says that using reference counting and copy-on-write to manage memory is also the main mechanism of PHP memory management
------Solution--------------------
China's recruitment is always so many nouns, so many theories, development time also depends on the specific ability of
The above is what is the garbage collection mechanism of PHP? The content of the solution, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!