Solved

can I increase number of bytes in php.ini

Posted on 2014-04-07
5
435 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 125 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:
RQuadling earned 125 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 26

Assisted Solution

by:MacroShadow
MacroShadow earned 125 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 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 125 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now