Does an array of objects discard only an array or all objects?

I have an array of objects. If I call unset ($ array), will it disable all objects in the AND array, or just an array? Suppose these objects are not mentioned anywhere else.

+3
source share
3 answers

If this array contains a single object reference, then yes. Otherwise, no. Also, something needs to be remembered from the PHP documentation:

unset () does what it calls - disable the variable. This does not immediately release memory. The PHP garbage collector will do this when it sees seizures - at will, as soon as these processor cycles are not needed anyway, or even before the script runs out of memory, whatever the first happens.

+2
source

GSto is right ... Only a garbadge PHP builder can free memory. unset () a variable or setting it to NULL can speed up the process of collecting "garbadge collect" (at the price of processor cycles), but there is no way to directly free some memory (à la C ++, where "delete" will actually free memory).

I asked a similar question a while ago on the forum, and this is what I got:

From Fou-Lu @ codingforums.com:

, (, mysql_free_result). , , . , . , gc , . , , , , , script ( ). unset , gc . , , , HashMaps C , , . , GC , zval, , ( , ).

http://www.codingforums.com/showthread.php?t=184164

+1

Source: https://habr.com/ru/post/1729605/


All Articles