Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] [OT] PHP memory problem Michael Orlitzky <michael@××××××××.com>