Gentoo Archives: gentoo-user

From: Michael Orlitzky <michael@××××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] PHP memory problem
Date: Fri, 15 Apr 2011 16:51:34
Message-Id: 4DA8773F.1000602@orlitzky.com
In Reply to: Re: [gentoo-user] [OT] PHP memory problem by Dan Johansson
1 On 04/15/2011 11:26 AM, Dan Johansson wrote:
2 > On Thursday 14 April 2011 03.12:34 Michael Orlitzky wrote:
3 >> On 04/13/2011 02:42 PM, Dan Johansson wrote:
4 >>> I know this is Off-topic but I also know there are a lot of smart people
5 >>> "lurking" on this list.
6 >>>
7 >>> I have a PHP-script that does not run from a web-server but directly in a
8 >>> shell. When I run it I get the following error:
9 >>>
10 >>> # ./dj.php
11 >>> PHP Fatal error: Allowed memory size of 100663296 bytes exhausted (tried
12 >>> to allocate 104 bytes) in /usr/local/scripts/includes/dj.inc on line 79
13 >>> Allowed memory size of 100663296 bytes exhausted (tried to allocate 24
14 >>> bytes)
15 >>>
16 >>> My scripts starts with:
17 >>> #!/usr/bin/php
18 >>> <?php
19 >>>
20 >>> ini_set('memory_limit', '4192M');
21 >>>
22 >>> include "dj.inc";
23 >>>
24 >>> And in php.ini I have:
25 >>> memory_limit = 1G ; Maximum amount of memory a script may consume
26 >>>
27 >>> Why does PHP not honor my memory limits?
28 >>> I have set 1GB in php.ini and 4192MB (I know that is more then 1GB) and
29 >>> the scripts fails at 100663296 bytes (~ 96MB). I have also tried with
30 >>> other memory settings but I always end up with with the failure at
31 >>> ~96MB. The host has enough RAM (32GB) to support the script.
32 >>>
33 >>> Any suggestions on how to solve the issue (short of rewriting the script
34 >>> in C or C++)?
35 >>
36 >> The use of 'G' as a unit was only "recently" added, in PHP 5.1.0. Try
37 >> using 'M' instead, and multiplying by 1024.
38 >>
39 >> I would also suggest using a number under 4 gigabytes, as you risk
40 >> overflowing a 32-bit integer. Does '3072M' work?
41 >
42 > Thanks, that was it. Changing 4G to 4192M in pnp.ini did solve the issue.
43 >
44 > Regards,
45
46 Life lesson: if you ever have a PHP problem and think, "there's no way
47 that's the problem, nobody is that retarded." That's probably the problem =)