By default it returns the current script that runs. There is a parameter since 5.2 to get the usage for the system.
AFAIK it always returns the memory used (or allocated) from the system to the
current script (page being processed) for the
current visitor. And this is what the memory limits in php.ini refer to. I don't think there is any simple way, in PHP, to monitor the usage by all concurrent visitors (other pages) on your account, and especially other websites on the virtual host, unless you had some kind of server-side tool monitoring memory usage?
The $real_usage parameter allows you to check the
actual memory used by your script. I'm guessing that when your script runs, emalloc() will allocate
chunks of memory that it thinks will be reqd. Your script may not actually require all of this allocated memory (real_usage), or it may require more, in which case emalloc() will allocate another chunk (NB: this is how
I think it works). If you monitor memory_get_usage() throughout the course of your scripts, this appears to be what's happening. memory_get_usage(false) increases in blocks. memory_get_usage(
true) - real usage - is always less than memory_get_usage(false) - allocated usage. However, I assume that the allocated usage determines if you run out of memory or not!