Setting memory limits for any server
Posted: Tue Oct 25, 2011 11:27 am
Hi all - first post...
So I have an app which needs to run on many different servers - probably a bunch of virtual hosts and some dedicated. Basically it could be running in hundreds of places. This app uses a LOT of memory (for image manipulation) so for testing I set it to 1024M on my own server using php.ini, but of course this can't be relied upon in many environments, and the .htaccess method can give you a 500 error on some servers so that's out. Basically my only options are to set it in php.ini and put in the install requirements (already fairly steep) that you must have access to it, set it in every script with ini_set, or both.
Now here's the problem - I want to warn users if they are about to process files which will take them over the memory limit, but ini_get("memory_limit") only returns whatever I wrote in ini_set or php.ini, not the _actual_ available memory. I can set memory_limit to 100000M if I want and it still returns that. Obviously I don't have that much Memory so it's not behaving as I expected.
So... how can I find the actual available memory, and what's the best way to set it to work on multiple servers?
Any help much appreciated!
Cheers
So I have an app which needs to run on many different servers - probably a bunch of virtual hosts and some dedicated. Basically it could be running in hundreds of places. This app uses a LOT of memory (for image manipulation) so for testing I set it to 1024M on my own server using php.ini, but of course this can't be relied upon in many environments, and the .htaccess method can give you a 500 error on some servers so that's out. Basically my only options are to set it in php.ini and put in the install requirements (already fairly steep) that you must have access to it, set it in every script with ini_set, or both.
Now here's the problem - I want to warn users if they are about to process files which will take them over the memory limit, but ini_get("memory_limit") only returns whatever I wrote in ini_set or php.ini, not the _actual_ available memory. I can set memory_limit to 100000M if I want and it still returns that. Obviously I don't have that much Memory so it's not behaving as I expected.
So... how can I find the actual available memory, and what's the best way to set it to work on multiple servers?
Any help much appreciated!
Cheers