Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] [OT] PHP memory problem Dan Johansson <Dan.Johansson@×××.nu>