maddogandnoriko Posted March 30, 2009 Share Posted March 30, 2009 My script is importing a 400-500k xml file and putting it into an array. I am getting an error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 40 bytes) in /Applications/MAMP/htdocs/VideoMainframe/includes/classes/simplexml.php on line 282 I know what it means I think, out of 8megs of memory. Something is wrong. Is there a way to determine how much memory a script is using? Like echo or print the value so i can try to see where the memory spikes up? Also...any hints on tracking this error would be a great help. I will look for infinite loops, but a quick look revealed none. Is there a way to print ALL vars available to the script? Maybe I can spot it that way... Oh yeah I changed all of my requires to require_once too. There is too much code in too many files to post yet.....until I can narrow the problem down. thank you very very much, maddogandnoriko Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted March 30, 2009 Share Posted March 30, 2009 memory_get_usage() and memory_get_peak_usage() Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted March 30, 2009 Share Posted March 30, 2009 Note that certain functions in PHP such as manipulating graphics or XML are very memory intensive Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted March 31, 2009 Author Share Posted March 31, 2009 would you expect a 450k file take 8M though? Thank you for the memory functions. I am trying now to pinpoint the problem. maddogandnoriko Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 31, 2009 Share Posted March 31, 2009 Your code is either doing something that directly consumes a lot of memory or it has a logic error, like a loop that never ends, that causes all available memory to be consumed. Posting your code would be the quickest way for someone else to determine the most likely cause. Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted March 31, 2009 Author Share Posted March 31, 2009 I was using a simplexml class that was created for ph pre5.xx. I have decided to abandon that and use php5. For loading a large(ish) file like 400-500k, which would take up less memory, simplexml or xml_parser? I really can't post the code it is spread across a number of includes and classes. I am trying to narrow it down a bit so I can post the offending code. maddogandnoriko Quote Link to comment Share on other sites More sharing options...
lostnucleus Posted March 31, 2009 Share Posted March 31, 2009 "tried to allocate 40 bytes" u just need 40 bytes of extra memory , give it to your script by editing php.ini file search for "8" and make it 9 ,this will make your script no matter how much of this memory is getting wasted...... Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted March 31, 2009 Author Share Posted March 31, 2009 I didn't want to just add more memory...that seems like more of a bandaid than a fix. It doesn't seem to me like it should take that much memory. maddogandnoriko Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted April 1, 2009 Author Share Posted April 1, 2009 I narrowed my problem down to an xml class I was using to be php4 compatible. I did not write the class so I am just going to ditch it and use the full potential of php5. Thank you all for helping me locate the problem. maddogandnoriko 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.