Skip to content

[2.3] [WebProfiler] Add PHP memory_limit to WDT #7037

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% set text %}
<div class="sf-toolbar-info-piece">
<b>Memory usage</b>
<span>{{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB</span>
<span>{{ '%.1f'|format(collector.memory / 1024 / 1024) }} / {{ collector.memoryLimit == -1 ? '&infin;' : collector.memoryLimit }} MB</span>
</div>
{% endset %}
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': false } %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class MemoryDataCollector extends DataCollector
{
public function __construct()
{
$this->data = array('memory' => 0);
$this->data = array(
'memory' => 0,
'memory_limit' => rtrim(ini_get('memory_limit'), 'M')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need more complex parser of size as decribed in http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, very useful - thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, this functions minor diffirent when parse 010M for examples - php get this as 8M

);
}

/**
Expand All @@ -44,6 +47,16 @@ public function getMemory()
return $this->data['memory'];
}

/**
* Gets the PHP memory limit.
*
* @return integer The memory limit
*/
public function getMemoryLimit()
{
return $this->data['memory_limit'];
}

/**
* Updates the memory usage data.
*/
Expand Down