如何解决共享主机中的内存限制问题

i am getting memory limit error while loading some of the pages of my website.

My issue is, i don't have rights to modify memory_limit in php.ini so is there any other way to override this settings ?

I am getting following error.

Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 122880 bytes) in /xx/xx/xx/plugins/otbcCompanyPlugin/lib/model/om/BaseOtbcCompanyCompanyPeer.php on line 1567

i tried:

ini_set('memory_limit', '512M');
echo ini_get('memory_limit');exit; // prints 90M

And i tried following in .htaccess

<IfModule mod_php5.c>
php_value memory_limit 512m
</IfModule>

and

<IfModule mod_php.c>
php_value memory_limit 512m
</IfModule>

but didn't work.

you can check phpinfo().

so is there anything missed by me ?

you can try to add your owen php.ini file in wich you specify :

memory_limit = 512M

to do so :

  1. create a php.ini file in your root folder
  2. add memory_limit = 512M
  3. create .htaccess file and add this line :

SetEnv PHPRC /home/username/folder/php.ini

this will load your custom instructions in your php.ini

to make sure just run the

<?php phpinfo() ?>

I have encountered the same issue. But it's pretty easy:

cPanel > section Software/Services > Select PHP Version menu.

Click on Switch to PHP extensions and there you will see the option for raising the php memory limit as memory_limit.

In some hosts, you can configure the custom php.ini file from here too.