Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

can I increase number of bytes in php.ini

Posted on 2014-04-07
5
Medium Priority
?
470 Views
Last Modified: 2014-04-07
running a content management system (many php files)
script raise error E_ERROR with messgae "allowed memory size of 134217728 bytes exhausted (tried to allocate 190464 bytes) at file.php line 933
Execution can not continue.


Is this a php.ini change
0
Comment
Question by:rgb192
5 Comments
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 500 total points
ID: 39982841
What is the name of CMS ? is it Wordpress or Joomla?  Also what is the value of "memory_limit" in your php.ini ? I guess this needs to be increased as per the initial value? Normally it can be "128M"
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 500 total points
ID: 39982843
Yes it is. For example:

memory_limit = 1G

See http://www.php.net/manual/en/ini.core.php#ini.memory-limit for more details.

You can also add ...

ini_set('memory_limit', '1G');

in your code.

You can use the shorthand (K, M, G) or the full number.

1G = 1 gigabyte. A LOT of memory for a PHP script.

You may be better off refactoring the code into separate processes, or not trying to process all the data at once.

Can you give some idea of what the script/process is doing?
0
 
LVL 28

Assisted Solution

by:MacroShadow
MacroShadow earned 500 total points
ID: 39982849
There is a problem with the script, perhaps a loop gone wild, opening and reading a very large text file etc.

While there are simple solutions, your best bet would be to find the hole and plug it rather than build a bridge over it.

If you do want a workaround, you can try any of the following methods:

1. ini_set('memory_limit', '-1'); NOT recommended, it may potentially leave your server open to malicious attacks via large data posts.
2. Increase your maximum memory limit to 64MB in your php.ini file (memory_limit = 64M ; Maximum amount of memory a script may consume (64MB))
3.  Add this to an .htaccess file: php_value memory_limit 64M
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 500 total points
ID: 39982869
There are many ways to raise the memory size, but rarely are there reasons to do so.  It might be better to examine line 933 of file.php, and it surrounding code, to determine why this error is occurring.  Some possible issues:

1. Conversion of a string into an array or object with many properties, such as might be generated by explode().  PHP arrays and objects are very large data structures.

2. Reading a large file with file() or file_get_contents().

3. Fetching the results of a SELECT query that had no LIMIT clause.

4. An unterminated loop caused by a program logic error.
0
 

Author Closing Comment

by:rgb192
ID: 39983084
ini set or php.ini

both work: I used php.ini

thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question