3

Is there a way I can know at what point the script has used the most memory and how much it was?

I know memory_get_usage(), but that will return the current memory usage, right?

So if you call it like when the script ends you get the lowest memory count because PHP has freed the memory for most of the stuff.

2
  • Try storing it after every line you want information on, if it was more memory usage than the previous greatest memory usage. Commented Dec 6, 2011 at 3:11
  • i prefer to use the os to determine memory usage, ps in linux. Commented Dec 6, 2011 at 3:42

1 Answer 1

5

would memory_get_peak_usage() work for you? (Introduce in 5.2.0, enable by default in 5.2.1)

http://php.net/manual/en/function.memory-get-peak-usage.php

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

2 Comments

I dont think that works, I get a rly low number, a little more than memory_get_usage. And that's not possible because I'm creating like 10 db tables at some point
I think it is, just b/c it's lower then what you would think doesn't mean it's not working. Creating tables happens in MySQL not php. Here's another article from IBM about it ibm.com/developerworks/opensource/library/os-php-v521

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.