public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] [OT] PHP memory problem
@ 2011-04-13 18:42 Dan Johansson
  2011-04-14  1:12 ` Michael Orlitzky
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Johansson @ 2011-04-13 18:42 UTC (permalink / raw
  To: gentoo-user

I know this is Off-topic but I also know there are a lot of smart people 
"lurking" on this list.

I have a PHP-script that does not run from a web-server but directly in a 
shell. When I run it I get the following error:

# ./dj.php
PHP Fatal error:  Allowed memory size of 100663296 bytes exhausted (tried to 
allocate 104 bytes) in /usr/local/scripts/includes/dj.inc on line 79
Allowed memory size of 100663296 bytes exhausted (tried to allocate 24 bytes)

My scripts starts with:
#!/usr/bin/php
<?php

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

include "dj.inc";

And in php.ini I have:
memory_limit = 1G      ; Maximum amount of memory a script may consume

Why does PHP not honor my memory limits?
I have set 1GB in php.ini and 4192MB (I know that is more then 1GB) and the 
scripts fails at 100663296 bytes (~ 96MB). I have also tried with other memory 
settings but I always end up with with the failure at ~96MB. The host has 
enough RAM (32GB) to support the script.

Any suggestions on how to solve the issue (short of rewriting the script in C 
or C++)?

Regards,
-- 
Dan Johansson, <http://www.dmj.nu>
***************************************************
This message is printed on 100% recycled electrons!
***************************************************



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] [OT] PHP memory problem
  2011-04-13 18:42 [gentoo-user] [OT] PHP memory problem Dan Johansson
@ 2011-04-14  1:12 ` Michael Orlitzky
  2011-04-15 15:26   ` Dan Johansson
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Orlitzky @ 2011-04-14  1:12 UTC (permalink / raw
  To: gentoo-user

On 04/13/2011 02:42 PM, Dan Johansson wrote:
> I know this is Off-topic but I also know there are a lot of smart people 
> "lurking" on this list.
> 
> I have a PHP-script that does not run from a web-server but directly in a 
> shell. When I run it I get the following error:
> 
> # ./dj.php
> PHP Fatal error:  Allowed memory size of 100663296 bytes exhausted (tried to 
> allocate 104 bytes) in /usr/local/scripts/includes/dj.inc on line 79
> Allowed memory size of 100663296 bytes exhausted (tried to allocate 24 bytes)
> 
> My scripts starts with:
> #!/usr/bin/php
> <?php
> 
> ini_set('memory_limit', '4192M');
> 
> include "dj.inc";
> 
> And in php.ini I have:
> memory_limit = 1G      ; Maximum amount of memory a script may consume
> 
> Why does PHP not honor my memory limits?
> I have set 1GB in php.ini and 4192MB (I know that is more then 1GB) and the 
> scripts fails at 100663296 bytes (~ 96MB). I have also tried with other memory 
> settings but I always end up with with the failure at ~96MB. The host has 
> enough RAM (32GB) to support the script.
> 
> Any suggestions on how to solve the issue (short of rewriting the script in C 
> or C++)?

The use of 'G' as a unit was only "recently" added, in PHP 5.1.0. Try
using 'M' instead, and multiplying by 1024.

I would also suggest using a number under 4 gigabytes, as you risk
overflowing a 32-bit integer. Does '3072M' work?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] [OT] PHP memory problem
  2011-04-14  1:12 ` Michael Orlitzky
@ 2011-04-15 15:26   ` Dan Johansson
  2011-04-15 16:50     ` Michael Orlitzky
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Johansson @ 2011-04-15 15:26 UTC (permalink / raw
  To: gentoo-user

On Thursday 14 April 2011 03.12:34 Michael Orlitzky wrote:
> On 04/13/2011 02:42 PM, Dan Johansson wrote:
> > I know this is Off-topic but I also know there are a lot of smart people
> > "lurking" on this list.
> > 
> > I have a PHP-script that does not run from a web-server but directly in a
> > shell. When I run it I get the following error:
> > 
> > # ./dj.php
> > PHP Fatal error:  Allowed memory size of 100663296 bytes exhausted (tried
> > to allocate 104 bytes) in /usr/local/scripts/includes/dj.inc on line 79
> > Allowed memory size of 100663296 bytes exhausted (tried to allocate 24
> > bytes)
> > 
> > My scripts starts with:
> > #!/usr/bin/php
> > <?php
> > 
> > ini_set('memory_limit', '4192M');
> > 
> > include "dj.inc";
> > 
> > And in php.ini I have:
> > memory_limit = 1G      ; Maximum amount of memory a script may consume
> > 
> > Why does PHP not honor my memory limits?
> > I have set 1GB in php.ini and 4192MB (I know that is more then 1GB) and
> > the scripts fails at 100663296 bytes (~ 96MB). I have also tried with
> > other memory settings but I always end up with with the failure at
> > ~96MB. The host has enough RAM (32GB) to support the script.
> > 
> > Any suggestions on how to solve the issue (short of rewriting the script
> > in C or C++)?
> 
> The use of 'G' as a unit was only "recently" added, in PHP 5.1.0. Try
> using 'M' instead, and multiplying by 1024.
> 
> I would also suggest using a number under 4 gigabytes, as you risk
> overflowing a 32-bit integer. Does '3072M' work?

Thanks, that was it. Changing 4G to 4192M in pnp.ini did solve the issue.

Regards,
-- 
Dan Johansson, <http://www.dmj.nu>
***************************************************
This message is printed on 100% recycled electrons!
***************************************************



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] [OT] PHP memory problem
  2011-04-15 15:26   ` Dan Johansson
@ 2011-04-15 16:50     ` Michael Orlitzky
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Orlitzky @ 2011-04-15 16:50 UTC (permalink / raw
  To: gentoo-user

On 04/15/2011 11:26 AM, Dan Johansson wrote:
> On Thursday 14 April 2011 03.12:34 Michael Orlitzky wrote:
>> On 04/13/2011 02:42 PM, Dan Johansson wrote:
>>> I know this is Off-topic but I also know there are a lot of smart people
>>> "lurking" on this list.
>>>
>>> I have a PHP-script that does not run from a web-server but directly in a
>>> shell. When I run it I get the following error:
>>>
>>> # ./dj.php
>>> PHP Fatal error:  Allowed memory size of 100663296 bytes exhausted (tried
>>> to allocate 104 bytes) in /usr/local/scripts/includes/dj.inc on line 79
>>> Allowed memory size of 100663296 bytes exhausted (tried to allocate 24
>>> bytes)
>>>
>>> My scripts starts with:
>>> #!/usr/bin/php
>>> <?php
>>>
>>> ini_set('memory_limit', '4192M');
>>>
>>> include "dj.inc";
>>>
>>> And in php.ini I have:
>>> memory_limit = 1G      ; Maximum amount of memory a script may consume
>>>
>>> Why does PHP not honor my memory limits?
>>> I have set 1GB in php.ini and 4192MB (I know that is more then 1GB) and
>>> the scripts fails at 100663296 bytes (~ 96MB). I have also tried with
>>> other memory settings but I always end up with with the failure at
>>> ~96MB. The host has enough RAM (32GB) to support the script.
>>>
>>> Any suggestions on how to solve the issue (short of rewriting the script
>>> in C or C++)?
>>
>> The use of 'G' as a unit was only "recently" added, in PHP 5.1.0. Try
>> using 'M' instead, and multiplying by 1024.
>>
>> I would also suggest using a number under 4 gigabytes, as you risk
>> overflowing a 32-bit integer. Does '3072M' work?
> 
> Thanks, that was it. Changing 4G to 4192M in pnp.ini did solve the issue.
> 
> Regards,

Life lesson: if you ever have a PHP problem and think, "there's no way
that's the problem, nobody is that retarded." That's probably the problem =)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-15 16:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 18:42 [gentoo-user] [OT] PHP memory problem Dan Johansson
2011-04-14  1:12 ` Michael Orlitzky
2011-04-15 15:26   ` Dan Johansson
2011-04-15 16:50     ` Michael Orlitzky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox