Answer the question
In order to leave comments, you need to log in
How to deal with memory in PHP?
There is a code:
echo memory_get_usage();
$a = 'a';
echo memory_get_usage();
echo memory_get_usage();
$a = 'a';
$b = 'b';
echo memory_get_usage();
$a = 'abcdefghjklmnopqr';
Returns the amount of memory, in bytes, that has been allocated to the PHP script so far.
Answer the question
In order to leave comments, you need to log in
1) per running PHP process
2) Memory is allocated in blocks (with a margin), since PHP is not a strongly typed language, and this variable can (unexpectedly) become a boolean or just an array
3) More likely the increase (which you observe) is not a block reservation memory for data, and the occupied memory for a link to the memory block (in which the data is stored), and possibly for the data themselves, the memory is used from an already reserved area
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question