Hi.
1) How to check if there's any upper limit of memory in my web hosting? If s, how much?
2) What is the best way to increase my memory limit?
There're 3 ways:
- php.ini
- index.php
- settings.php

Which one should I edit?
What're the pros and cons?
What code do I need to add (for each file separately)?

Thanks!

Comments

Wai_Wai’s picture

Any help?

london3’s picture

If you run out of PHP memory. You'll need to either uninstall some modules or increase the memory_limit variable in php.ini.

/etc/php4/apache2/php.ini
; change from 8MB to 16MB
memory_limit = 16M ; Maximum amount of memory a script may consume (8MB)

Wai_Wai’s picture

I can't even find etc in my main folder, and in public_html folder.
Out of luck :(
Probably my web hoster hid it.

pgassner’s picture

Add this to your settings.php:

ini_set('memory_limit', '100M');

It worked for me on a server that I have no control over. I had to set the limit so high in order to get some image conversions to work...

Wai_Wai’s picture

Hey.
It seems the above doesn't work.
I don't know what's wrong.
What web hoster are you using?

After all, would you mind trying to do the following:

1) Create an info.php

<?php 
phpinfo(); 
?>

2) Upload it to anywhere in your website.
Then access it.

3) A page will load up showing you a lot ofinformation about PHP.
Look for the following info:
........................Configuration

..........................PHP Core

Directive.........Local Value......Master Value
.....
memory_limit....?M................?M (<-- Look for these values!)

Tell me what're the value of the above in your case.
Thanks a lot.

pgassner’s picture

It worked for me on a server running Linux with Apache 1 and PHP 4. My phpinfo says the memory limit is 8M in both cases which it really isn't, though, because my webapp crashed hard before I set the limit higher.

Wai_Wai’s picture

It seems the phpinfo is not reliable. :P
So I think the settings will work on my server too.

ZenCoder’s picture

I am trying to find out what my memory_limit is, but phpinfo() simply doesn't report the value.

I searched for "memory" and then just "mem"

Shared Host
Apache 1.3.37
PHP 4.4.4
Zend Memory Manager enabled
Server API CGI

Can someone explain why the value isn't there?

jiangxijay’s picture

I've placed php.ini files in numerous locations, and I also tried the ini memory directive in .htaccess.

No memory limit is shown in phpinfo() in the root Drupal directory.

ZenCoder’s picture

My host has php running via CGI rather than as an apache module (I know this isn't a good setting for drupal or any other app that does lots of small bits of php & sql). There is no memory limit set. Well I am sure there is a limit but its handled by the OS and not php.

swatichouhan012’s picture

you can increase the memory limit in your php.ini file.
memory_limit = 2048M ;

If you have no idea about the location of php.ini file so you can add this line

ini_set('memory_limit', '100M');
in your settings.php file

omrmankar’s picture

but what is the exact location in the settings.php let me know all file structure?

Best regards,

Omprakash Mankar
Senior Drupal Developer

swatichouhan012’s picture

you can add this line any where in the file.

omrmankar’s picture

Thanks

Best regards,

Omprakash Mankar
Senior Drupal Developer

kbahey’s picture

php.ini is the best way.

However, this will work only if your hosting company allows such setting in such file.

--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Wai_Wai’s picture

I am allowed to create php.ini
But how can I know if the settings work?

sepeck’s picture

How to check? Use the venerable phpinfo function and look for the settings or ask your host provider.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Wai_Wai’s picture

Hi.
Here's what I once tried to add memory_limit code in:
- php.ini
- settings.php

Then I tried to verify the change by uploading 7 running this *.php:

<?php 
phpinfo(); 
?>

the following info shows:
........................Configuration

..........................PHP Core

Directive.........Local Value......Master Value
memory_limit....8M................8M

Why no change is made?
Does it mean that the memory_limit setting fails?
Is the result reliable to tell no change occurs?

Thanks.

adlitinc’s picture

if you have changed a setting in php.ini you would need to restart the apache service for the change to take effect

ravi_admec’s picture

this is for godaddy linux shared hosting users.

settings.php

If Drupal is already installed, you can edit sites/default/settings.php. This method will affect only the site using this file.
Locate the PHP settings section and add the following line at the end of that section:
ini_set('memory_limit', '64M');

It worked for me today.

Thanks

auxiliaryjoel’s picture

I increased my memory limit to 364MB, (have confirmed on status report page) but I still can't submit webform forms. the submit button triggers a white error page with this code:
 

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: SQLSTATE[42S02]: Base table or view not found: 1146 Table &#039;jjweb2018.webform&#039; doesn&#039;t exist: SELECT w.next_serial AS next_serial
FROM
{webform} w
WHERE webform_id = :db_condition_placeholder_0 FOR UPDATE; Array
(
    [:db_condition_placeholder_0] =&gt; contact_jeremiah
)
 in <em class="placeholder">Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;save()</em> (line <em class="placeholder">783</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php</em>). <pre class="backtrace">Drupal\Core\Database\Statement-&gt;execute(Array, Array) (Line: 625)
Drupal\Core\Database\Connection-&gt;query(&#039;SELECT w.next_serial AS next_serial
FROM
{webform} w
WHERE webform_id = :db_condition_placeholder_0 FOR UPDATE&#039;, Array, Array) (Line: 358)
Drupal\Core\Database\Driver\mysql\Connection-&gt;query(&#039;SELECT w.next_serial AS next_serial
FROM
{webform} w
WHERE webform_id = :db_condition_placeholder_0 FOR UPDATE&#039;, Array, Array) (Line: 510)
Drupal\Core\Database\Query\Select-&gt;execute() (Line: 277)
Drupal\webform\WebformEntityStorage-&gt;getSerial(Object) (Line: 897)
Drupal\webform\WebformSubmissionStorage-&gt;doSave(NULL, Object) (Line: 429)
Drupal\Core\Entity\EntityStorageBase-&gt;save(Object) (Line: 774)
Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;save(Object) (Line: 390)
Drupal\Core\Entity\Entity-&gt;save() (Line: 757)
Drupal\webform\Entity\WebformSubmission-&gt;save() (Line: 1634)
Drupal\webform\WebformSubmissionForm-&gt;save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter-&gt;executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter-&gt;doSubmitForm(Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;webform_submission_contact_jeremiah_add_form&#039;, Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;webform_submission_contact_jeremiah_add_form&#039;, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder-&gt;getForm(Object, &#039;add&#039;) (Line: 1030)
Drupal\webform\Entity\Webform-&gt;getSubmissionForm() (Line: 84)
Drupal\webform\Controller\WebformEntityController-&gt;addForm(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 669)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>

Does anyone know how I can address WEBFORM vs MYSQL DATABASE issues (as that seems to be the issue...)?

shashinext’s picture

If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 64M 

webdevelopmentinstitute.com

www.nextgeducation.com