linux - PHP Memory Allocation Limit Causes -
i have 2 servers
both server's have same php memory_limit of 128m of data.
my dev server runs script fine, while on prod server receiving fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 32 bytes) in ...
my question other reasons running out of memory in prod environment though php memory_limits same?
preface
php module runs top of apache [httpd server] involves linking php interpreter against library of hooks published webserver
cause
now can exhaust due scripts running allocating memory [ram] & reach threshold & such errors. illustration big loops running & saving lots of info in memory may on run memory
possible optimization can do
memory_limit = 32m server's main php.ini file (recommended, if have access) php_value memory_limit 32m in .htaccess file in
these work around pages run out of memory
ini_set('memory_limit', '-1'); overrides default php memory limit (on individual php pages wherever need memory)
also optimization can on http server (apache.conf or http.conf)
rlimitcpu,rlimitnproc, rlimitmem parameters can adusted
since running out of memory can adjust rlimitmem
syntax: rlimitmem soft-bytes [hard-bytes] example: rlimitmem 1048576 2097152 directive sets soft , hard limits maximum memory usage of process in bytes. takes 1 or 2 parameters. first parameter sets soft resource limit processes. sec parameter sets maximum resource limit. either parameter can number, or ``max'', indicates server limit should match maximum allowed operating scheme configuration. raising maximum resource limit requires server running user ``root'' or in initial start-up phase.
you can set lines in .htaccess files [since in shared hosting didnt have access php.ini & http.conf files
php linux memory out-of-memory dev-to-production
No comments:
Post a Comment