niwa3836 Posted August 15, 2008 Share Posted August 15, 2008 Hi, Hope I am posting this in the right place and someone feels able to help me design thinking. I am getting on fine with PHP generally, however I have noticed that a few of my programs hammer the disks quite hard and therefore I would like to store lots in arrays whilst I do the number crunching. The question is how far can you push arrays. In the old days (15 years ago when I did my last real programming I used to call malloc to make sure that there was memory available for the arrays. I dont see this now in codes, is it still used. So for instance how do I know (or can trap in code) whether an array of, lets say, 30,000 rows, or 10 fields or 20 chars each will cause some memory problems? What about 100,000? Anyone know as its difficult to test and of course I guess every machine that runs the code (different types of servers with different memory etc) may react differently. Am I barking up a tree, or more like a small daisy? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted August 15, 2008 Share Posted August 15, 2008 well you can set the amount of memory php will allow your script to use in php.ini that way you can have arrays as big as you want. Scott. Quote Link to comment Share on other sites More sharing options...
niwa3836 Posted August 15, 2008 Author Share Posted August 15, 2008 but how much memory do you allocate? From a design point of view do people actual do this, I havent changed any values as yet as want really to understand why and what to. Is there an incode trap for a failure? As I say some of the records to wander to 100,000 and would love to know if safe to do so. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 15, 2008 Share Posted August 15, 2008 By default PHP can consume up to 128MB, this can be changed from the php.ini (and/or your script) via the memory_limit directive. I do believe PHP has a built in function for seeing how much memory your script is using, However I cant remember the name of the function. Quote Link to comment Share on other sites More sharing options...
ratcateme Posted August 15, 2008 Share Posted August 15, 2008 i have found memory_get_usage() and memory_get_peak_usage() you could set the max memory value really high then use those to find out how much memory you are using and then set the max value to something similar. Scott. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.