7

I've written a very big PHP file with lots of variables and equations. Now I'm going to host it on my college website, but with our hosting there is a memory consumption limit. There will be thousands of hits to that page as soon as we link it.

So I want to know the consumed memory of my PHP file when it is requested once,so that we can calculate the usage of memory resources and based on that determine how to proceed.

0

3 Answers 3

16

Have a look at:

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

and

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

maybe, these can help you.

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

Comments

0

could be wrong but apachebench might be able to help you here. It'll give you an idea of how your college servers will cope with the load.

http://httpd.apache.org/docs/2.0/programs/ab.html

Comments

0

If you use an auto-loader for your classes, it might be useful to include this code at the beginning of the function:

function autoloader($class) 
{
    $memory = memory_get_usage (FALSE );
    print ("Autoloading $class - memory is $memory<br>");

  (autoloader code here)
}

As I develop my application, it gives me a rough idea about the memory my script is using. I never optimize my application until the very end so every class is loaded individually, which is definitely useful to see how much memory is being used as each one is loaded.

I hope this helps somebody :)

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.