From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-user+bounces-121627-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QA53S-0000IO-Ob
	for garchives@archives.gentoo.org; Wed, 13 Apr 2011 18:44:42 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 7610F1C11B;
	Wed, 13 Apr 2011 18:42:53 +0000 (UTC)
Received: from smtp2.mail.fcom.ch (smtp2.mail.fcom.ch [212.60.46.171])
	by pigeon.gentoo.org (Postfix) with ESMTP id 3DD2A1C11B
	for <gentoo-user@lists.gentoo.org>; Wed, 13 Apr 2011 18:42:53 +0000 (UTC)
Received: from smtp2.mail.fcom.ch (localhost [127.0.0.1])
	by smtp2 (Postfix) with ESMTP id 2658318CC4
	for <gentoo-user@lists.gentoo.org>; Wed, 13 Apr 2011 20:42:51 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on smtp2.mail.fcom.ch
X-Spam-Level: 
X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_50,RCVD_IN_SORBS_DUL,
	RDNS_DYNAMIC,SPF_HELO_PASS autolearn=no version=3.2.5
Received: from dmj.nu (204-104-204-62-pool.cable.fcom.ch [62.204.104.204])
	by smtp2 (Postfix) with ESMTP id 1309F18119
	for <gentoo-user@lists.gentoo.org>; Wed, 13 Apr 2011 20:42:50 +0200 (CEST)
Received: from queen.localnet (queen.dmj.nu [192.168.1.11])
  by dmj.nu with ESMTP; Wed, 13 Apr 2011 20:42:50 +0200
  id 0000000000598E6C.000000004DA5EEAA.00005901
From: Dan Johansson <Dan.Johansson@dmj.nu>
To: gentoo-user@lists.gentoo.org
Subject: [gentoo-user] [OT] PHP memory problem
Date: Wed, 13 Apr 2011 20:42:49 +0200
User-Agent: KMail/1.13.5 (Linux/2.6.37-gentoo-r4; KDE/4.4.5; x86_64; ; )
X-Face: &pU{afj:B4l63kI+Lqyk~Sy4/whF_tOpA+G|\c?XeMpAaD/vgsopla?wk%#wum)
 =?utf-8?q?=2E/P7PL+=0A=09m?=@q{~IZ-Abs^fx8~&y=';Hf|q0QJ9'$hDLY-]G]qZi%D*]t,~cIK7&COJ+PB%k]I>
 =?utf-8?q?70nan=0A=09P4a4b?=,C!8S}q!8f'$0uXtH2dm2:Vcq6?KWwe/=VBL],r+d[~tG.JjxUv8\|`j:
X-message-flag: Using Microsoft software might be a security risk
Precedence: bulk
List-Post: <mailto:gentoo-user@lists.gentoo.org>
List-Help: <mailto:gentoo-user+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-user+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-user+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-user.gentoo.org>
X-BeenThere: gentoo-user@lists.gentoo.org
Reply-to: gentoo-user@lists.gentoo.org
MIME-Version: 1.0
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201104132042.49914.Dan.Johansson@dmj.nu>
X-AV-Checked: ClamAV using ClamSMTP
X-Archives-Salt: 
X-Archives-Hash: 032c026a8740532db9e35232fc4476d0

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!
***************************************************