Jump to content

Recommended Posts

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

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

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.