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.
The memory_get_usage function can be used to track the memory usage. The 'malloc' function is not used for every block required, instead a big chunk of system memory is allocated and the environment variable is changed and managed internally.
Memory Limit is Not The Same as RAM While RAM is the total available memory, the memory limit is per PHP process. That means that your site can consume e.g 10 GB of RAM, with a memory limit of 256 MB.
The right one for you depends on your system configuration. A typical appropriate memory limit for PHP running Drupal is 128MB per process; for sites with a lot of contributed modules or with high-memory pages, 256MB or even 512MB may be more appropriate.
To get the current memory usage, we can use the memory_get_usage() function, and to get the highest amount of memory used at any point, we can use the memory_get_peak_usage() function.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With