Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory-get-usage.xml Clarify what kind of memory we are talking about #4491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions reference/info/functions/memory-get-usage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<refentry xml:id="function.memory-get-usage" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>memory_get_usage</refname>
<refpurpose>Returns the amount of memory allocated to PHP</refpurpose>
<refpurpose>Returns the amount of memory consumed by PHP script or allocated by system to PHP process</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>memory_get_usage</methodname>
<methodparam choice="opt"><type>bool</type><parameter>real_usage</parameter><initializer>&false;</initializer></methodparam>
</methodsynopsis>
<para>
Returns the amount of memory, in bytes, that's currently being
allocated to your PHP script.
Returns the amount of memory, in bytes, that the PHP script is
currently using.
</para>
</refsect1>

Expand All @@ -27,15 +27,17 @@
<listitem>
<para>
Set this to &true; to get total memory allocated from
system, including unused pages.
If not set or &false; only the used memory is reported.
the system to the PHP process, including unused memory pages.
If not set or &false; only the memory used by PHP script is reported.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<note>
<para>PHP does not track memory that is not allocated by <literal>emalloc()</literal></para>
<para>
PHP tracks only memory that is allocated by the internal function <literal>emalloc()</literal>.
</para>
</note>
</refsect1>

Expand All @@ -54,18 +56,19 @@
<programlisting role="php">
<![CDATA[
<?php

// This is only an example, the numbers below will
// differ depending on your system
// differ depending on the specific system

echo memory_get_usage() . "\n"; // 36640
echo memory_get_usage(), "\n"; // 36640

$a = str_repeat("Hello", 4242);

echo memory_get_usage() . "\n"; // 57960
echo memory_get_usage(), "\n"; // 57960

unset($a);

echo memory_get_usage() . "\n"; // 36744
echo memory_get_usage(), "\n"; // 36744

?>
]]>
Expand Down