php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #37300 memory_limit disabled on windows
Submitted: 2006-05-04 02:48 UTC Modified: 2006-05-12 15:41 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: astinky at lycos dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.1.3 OS: Windows Server 2003
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-05-04 02:48 UTC] astinky at lycos dot com
Description:
------------
Re: http://bugs.php.net/bug.php?id=36568

It seems this is not quite fixed.

This test script below fails, with no error output and does not echo the memory limit at all.

This is on Apache 2.2.2 php 5.1.3 eAcclerator 0.9.5-b2.
(tested with eAcclerator disabled - same result)

The apache2handler I'm using is self compiled, but I suspect it is not the problem as another server (Windows Server 2003, II6 php 5.1.2 or php 5.1.3 shows similar symptoms)

I am using the posted windows binaries for php 5.1.3 and apche 2.2.2

Both servers show an error for the webserver exe in the event log on shutdown with the faulting module varying (php5ts.dll, php_mysql.dll, ntdll.dll, msvcrt.dll...) on previous searches of the bugs here this is always attributed to server misconfiguration. I have been running apache/php for years and am intimately fmiliar with its configuration and have been frustrated by this error appearing in recent php versions.

I'm going to take a look at the related php code tomorrow and will reprt any findings I might come up with.

I notice previous comments about no support for a memory limit in windows, but I'm sure it worked in php 5.0.5... (tried stting it to -1 which also fails) 

Thanks for any assistance you can offer.



Reproduce code:
---------------
<?php
echo 'memory_limit: ';
ini_set("memory_limit", "32M");
echo ini_get("memory_limit");
?>

Expected result:
----------------
I expect to be able to set the memory limit. (particularly for a script of mine that loads huge arrays from a 2.9 MB tab delimited text file - which worked fine in earler php5 versions but its output is truncated in php 5.1.2 and 5.1.3). I do not expect the webserver to fault on shutdown.

Actual result:
--------------
Unable to set memory limit, webserver faults on shutdown.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-11 10:10 UTC] astinky at lycos dot com
Additional info/correction:

Actually the weserver would fault on shutdown with Apache 2.2.0 - php 5.1.2 (and 5.1.3) if the hardcoded memory limit was exceeded.

With Apache 2.2.2 - php 5.1.3 (and 5.1.4) the webserver will fault at the time the memory limit is exceeded.

The IIS system mentioned above is running php as an ISAPI.

I usually set the memory limit in the php.ini anyway, not in the script. Still it has no effect.

If only the fgetcsv function was not so hard on resources I would not be having this issue. I could solve my problem by converting the tab delimited text file I am reading into a MySQL table, but I'd really like to just be able to read the text file in the script so it is more portable.

The problem persists in php 5.1.4.

I compared the zend_alloc.c of php 5.0.5 to php 5.1.4 and found some suspicious differences, but nothing I could say for sure is responsible.

Just let me know if there is any other info I can provide that may help.
 [2006-05-11 10:51 UTC] edink@php.net
Windows builds ship without memory limit feature.
This was done on purpose. I have changed the category to change request since we might consider changing it.
 [2006-05-11 13:49 UTC] astinky at lycos dot com
Ah, thanks.

The thing is, this memory intensive script of mine worked fine on php 5.0.5, but its output is truncated on php 5.1.2 and up. It generates no other errors. 

As well, our upload scripts used to allow a 40 MB file upload on php 5.0.5 and previous versions. I have not tested whether it still does, but I assume it is affected by the changes in memory limit behaviour on windows.

Something else has changed with respect to memory use on windows. Perhaps the harcoded memory limit of php has been reduced?

If I build 5.1.4 for Win32 from source myself can I enable the memory limit or change the hardcoded limit? (I suspect from your comment I can)

Thanks again for your attention to this matter, it is much appreciated.
 [2006-05-11 13:55 UTC] edink@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


Default php does not have any memory limit.

Please use php5handler2_2.dll if you're using apache 2.2
 [2006-05-11 14:02 UTC] astinky at lycos dot com
Perhaps whatever Dmitry did here:

http://bugs.php.net/bug.php?id=36568

Changed memory use on windows, without actually enabling the memry limit

I assume that the intention is that there should be no memory limit at all on windows?

If that is the case, then there is one now, I just can't change it. I know my script is not using the entire 1GB of system ram on this server (12 MB maybe...).

When my script stopped working corresponds to the time of the change in bug ID 36568.

I'd rather not rollback to php 5.0.5 or have to compile 5.1.4 myself but ultimately I'll have to if the old behaviour is not restrored or the memory limit fully enabled.

I'm not meaning to nag here, just filling in more info that I hope will be helpful. I'll find a solution one way or another but it is my hope that the old behaviour of memory use on windows will be restored or the memory limit will be fully enabled, whatever you guys think is appropriate.
 [2006-05-11 14:04 UTC] astinky at lycos dot com
Sorry, I missed your last comment before my last post.

I will indeed give that snapshot a try and report back as soon as I get it tested!
 [2006-05-11 14:09 UTC] edink@php.net
And please tell me what PHP extensions do you have enabled. Try with a minimal config to see if the problem disappears. I rather suspect crash has nothing to do with memory limit.

Also if possible please provide reproducing script.

 [2006-05-11 14:46 UTC] astinky at lycos dot com
Will do... just gimme a bit to download it, I'm on dial-up here.

Extensions in use:

extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_mysql.dll (compiled against libMySQL 5.0.21)
extension=php_sockets.dll
extension=php_pspell.dll
zend_extension_ts="eAccelerator.dll"

I get the same result without my build of eAcclerator 0.9.5-b2 (php 5.1.4) loaded, so that is not the cause.

Here is the memory intensive portion of the script in question:

	$shipdatarow = array();
	$shipcount = 0;
	$filename = "shiplist.txt";
	$fp=fopen("$filename","rt");
	while (($shipdata = fgetcsv($fp, 1569, chr(9))) !== FALSE) {
		if ($shipdata[0] == $shiprace[$WONlogonsubRace]) {
			$shipdatarow[$shipcount] = $shipdata;
			$shipcount++;
		}
	}

The file shiplist.txt is ~2.9MB in size.

I optimised it on an apache-php build on QNX I produced myself a few years ago, as it was originally developed on a windows server when there was no memory limit in php on windows and it needed on optimisation to run in a reasonable memory space under my apache-php build for QNX.


Here is the application in place:
http://www.dynaverse.net/webmap_op_sql/
however you will not be able to see the shipyards page without a forums login on our site and a character account on the game server.

I will zip up the works for you to look at (db passwords and some hostnames and paths removed) Much of the code is from when I first started with php (3.x) so don't laugh too hard...
here it is:
http://www.dynaverse.net/webmap_op_sql/webmap_togo.zip

I must emphasise that I did not have this problem with exactly the same config on php 5.0.5 so I know it is not the script or the extensions I am using.

Nevertheless, I will test a stripped down version at home that just opens the text file and loads a portion of it into an array. I'll do this with no extensions loaded.

Again it will take me some time to download as I'm on dial-up at home here.

To test it on our server I'll need to compile eAccelerator and php_mysql against this snapshot (and it seems you've saved me compiling an apache 2.2 module)

However the stripped down test on my home PC will get priority.
 [2006-05-11 15:50 UTC] astinky at lycos dot com
Well, using this code to test:

<?php
	$shipdatarow = array();
	$shipcount = 0;
	$filename = "shiplist.txt";
	$fp=fopen("$filename","rt");
	while (($shipdata = fgetcsv($fp, 1569, chr(9))) !== FALSE) {
		if ($shipdata[0] == "Mirak") {
			$shipdatarow[$shipcount] = $shipdata;
			$shipcount++;
		}
	}

echo $shipdatarow[0][2];
echo '<br><br>';
echo $shipdatarow[$shipcount-1][2];
unset($shipdatarow);
?>

I cannot reproduce the crash on either our server or my home PC.

However the output of the full script is still truncated on our server.

I am using identical configurations on the two machines, the only difference being that our server is running Windows Server 2003 and Symantec Corporate AV (not my choice, I hate Norton with a passion) and I'm running WinXP SP2 at home with no virus scanner.

This is still php 5.1.4.

I'll now test that snapshot at home and on the server to see the effect on my script and whether or not I can set the memory limit.

Its starting to look like I've sent you on a wild goose chase.
 [2006-05-11 18:17 UTC] astinky at lycos dot com
It seems

http://snaps.php.net/win32/php5.2-win32-latest.zip

changes faster than I can download it. (~1hr) I got a corrupted zip file. I got the source OK though.

I'l try:
http://snaps.php.net/win32/php5.2-win32-200605111430.zip
 [2006-05-11 19:55 UTC] astinky at lycos dot com
That snapshot still does not allow setting the memory_limit in either the script or the php.ini. I ran the snapshot as-is at home on WinXP SP2 with no extensions loaded at all. (aside: the apache 2.2 handler still reports itself as "Apache 2.0 Handler")

<?php
echo 'memory_limit: ';
echo ini_get("memory_limit");
?>

<?php
echo 'memory_limit: ';
ini_set("memory_limit", "32M");
echo ini_get("memory_limit");
?>

Both output only "memory_limit: " with no error generated.

My fgetcsv test script does not crash on this version either.

I'm kinda baffled at this point. If we get a working memory_limit for php on windows, great, I'll test it on
my live shipyards script to see if it is the issue causing it to stop short of completion, if not, I'll have to track down other changes since 5.0.5 that may be causing this issue for me.
 [2006-05-11 20:44 UTC] edink@php.net
Memory limit is not enabled in 5.2.0 (PHP runs somewhat slower when it is enabled), but I suspect that this has nothing to do with your problem.

 [2006-05-11 21:35 UTC] edink@php.net
Thing that has changed between 5.0 and 5.1 is that 5.1 seems to be more memory hungry, especially when it comes to stack.

The way to increase stack space availabe to PHP you can run:

EDITBIN /STACK:4194304  httpd.exe
in your Apache2.2\bin directory (editbin comes with vc++)

You should also decrease ThreadsPerChild to 50 from 250 in your httpd.conf to be able to handle 4MB stack.
 [2006-05-11 21:56 UTC] astinky at lycos dot com
Thanks for the tip, I'll give that a try.

I already run the apache winnt mpm like so:
Win32DisableAcceptEx
ThreadsPerChild     64
MaxRequestsPerChild   10000
(stabilises it considerably)

I'll try dropping ThreadsPerChild to 50 as well.
 [2006-05-11 22:20 UTC] astinky at lycos dot com
Hmmm, with this in mind I just re-read the ThreadStackSize Directive available in Apache since 2.1

http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadstacksize

Might give that a try first.
 [2006-05-12 15:28 UTC] astinky at lycos dot com
Well I tried a number of combinations of those changes and none of them resulted in complete output from my script so I reverted them all to my riginal settings.

However, on a lark I tried viewing the page in IE6 instead of Firefox 1.5.0.3 and voila! The script output was complete and intact!

Conclusion: Browser issue. <looks appropriately embarrased>

The webserver is no longer faulting and I'm somewhat mystified as to why, but hey, I'll take it.

So I guess I'll try a clean Firefox 1.5.0.3 install and see if the issue persists and if so report it to Mozilla.

Again, a thousand thanks for your patience and understanding, I've been a big fan of php for ages, so keep up the good work!
 [2006-05-12 15:41 UTC] edink@php.net
Ok. The issue was not memory limit, and we will keep it disabled for windows because of performance reasons. For now :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 16:01:29 2024 UTC