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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/ 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() Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-796953 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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-796956 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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-797734 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. Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-797745 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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-797871 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...... Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-797901 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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-798203 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 Link to comment https://forums.phpfreaks.com/topic/151769-solved-out-of-memory/#findComment-798786 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.