1

Do you know if there's a way to log how much memory is used in PHP scripts?.

I would like a log that tells me which objects are using more memory, which functions I need to improve, etc.

It would be something like memory_get_usage but for each line of code.

6
  • echo "MEMORY USAGE: ". memory_get_usage()."<br>"; which is a start. Commented May 24, 2014 at 13:25
  • I mean something like that but I won't copy that for each line of code... I was asking if there's a way to do that automatically. Commented May 24, 2014 at 13:27
  • 1
    Maybe there's something in the manual for it php.net/manual/en/function.memory-get-usage.php and Google the function. You may very well find something. But that's the function you need. Commented May 24, 2014 at 13:28
  • Already checked... there's nothing like the thing I'm looking for Commented May 24, 2014 at 13:33
  • This Q&A stackoverflow.com/q/2192657 and blog.gigavoice.com/php-data-structures after Googling "memory_get_usage() for individual items php" where you'll find more, I am sure. Commented May 24, 2014 at 13:35

1 Answer 1

1

Xdebug's execution trace might be closest to what you're looking for. It traces every include, function call and method call to a human-readable file that can optionally (with xdebug.show_mem_delta setting on) show the difference in memory usage between calls.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.