MadTechie Posted May 7, 2007 Share Posted May 7, 2007 i have a php script thats can run out of memory (basically the user overloads it), Now i plan to fix this but for now i wanted to manage the error, in my script i added <?php echo memory_get_usage()."-".memory_get_peak_usage(true)."<br />"; ?> into the loop and basically wanted to either handle the error or break the loop, but i can't seam to work out either 1. how to find the max amount of memory i can use or 2. capture the error. the error that displays is 578508-786432 1631084-6291456 2681008-11010048 3731308-15728640 4781348-20447232 5831764-25165824 Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 6297585 bytes) in /home/devico/public_html/class/UserExt.inc.php on line 150 Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/ Share on other sites More sharing options...
boo_lolly Posted May 7, 2007 Share Posted May 7, 2007 are you using a *nix operating system? Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247660 Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Author Share Posted May 7, 2007 Ahh good point, it is running on a unix system but maybe moved to a different *nix system or a windows one, i am trying my best to allow the system to work on all i don't want to use system() or exec() if possible hence the error handeling would be ok (stopping the error is better, i don't mean increase the memory but capture the error ) i hope that makes sence Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247665 Share on other sites More sharing options...
boo_lolly Posted May 7, 2007 Share Posted May 7, 2007 yeah that makes sense. i was thinking you wanted to fix the error, not catch it =). if you were to fix the error, one solution may be to repartition your filesystem and allocate more space to that directory. but to catch the error, i believe you should start by looking in your php.ini file. Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247679 Share on other sites More sharing options...
benjaminbeazy Posted May 7, 2007 Share Posted May 7, 2007 but to catch the error, i believe you should start by looking in your php.ini file. i think you're right unless you're willing to use exec() Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247681 Share on other sites More sharing options...
MadTechie Posted May 7, 2007 Author Share Posted May 7, 2007 is their a way to pull the "memory_limit" from the php.ini file?? if not how can i capture the error mid flow? PS i really don't want to use exec (i prefer to have it disabled on the server) and for error handerling i would prefer the error LOL Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247684 Share on other sites More sharing options...
benjaminbeazy Posted May 8, 2007 Share Posted May 8, 2007 i believe ini_get('memory_limit'); Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247688 Share on other sites More sharing options...
MadTechie Posted May 8, 2007 Author Share Posted May 8, 2007 I did try that but it kept failing before reaching the amount set.. then i noticed ini_set("memory_limit","24M"); D'oh i'll class this as solved! Link to comment https://forums.phpfreaks.com/topic/50420-solved-memory-handling/#findComment-247691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.