From:             soadlink at gmail dot com
Operating system: Ubuntu 6.10
PHP version:      5.2.1
PHP Bug Type:     Performance problem
Bug description:  Huge arrays cause large memory usage in Ubuntu, but not 
Windows

Description:
------------
I am working with a script that loads a list into an array and then echos
each word in the array on a new line. See the 'reproduce code' for the
code.

I run my scripts with the CLI (not on a website), and it works great in
Windows XP when loading lists as large as 375,000 words, and I can run
plenty of instances of this script without lag issues (8+ command lines
going at once!). But when I try to run the same script on Ubuntu 6.10 I
get the following error: Fatal error: Allowed memory size of 8388608 bytes
exhausted (tried to allocate 13491373 bytes). But that can easily be fixed
by setting a larger memory limit such as: ini_set("memory_limit","75M");

However I only have to increase the memory limit on Ubuntu, but not
Windows. And when I do up the memory limit on Ubuntu, only 1 or 2
instances can be run before the machine starts to bog down and get VERY
slow. I'd assume this is because php is trying to load the entire list
into memory in Ubuntu, but I am curious as to why Windows runs it fine. Is
there something I can change on Ubuntu to make it run better? Or is this a
bug with the Linux version oh PHP?

The PCs are the same that I'm working with (I just removed the Windows
install recently and put Ubuntu on there), and it has 1GB of ram, and an
AMD64 3200+ processor. I'm just wondering if there is something I need to
change to get the script to run like it did on Windows, ...without being a
memory hog or having to increase the memory limit (since I didnt have to on
Windows).

Reproduce code:
---------------
<?php
$loadlist = array_map("rtrim", file("c:\\list.txt"));
foreach ($loadlist as $word) {
echo ($word . "\n");
}
?>

Expected result:
----------------
I expect it to echo the words in the list (1 word per line). It works fine
on Windows, but on Ubuntu 6.10 it is very very laggy with multiple
instances, whereas with Windows it runs just fine. I can have dozens of
instances of the script running on Windows, but not Ubuntu.


-- 
Edit bug report at http://bugs.php.net/?id=40720&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40720&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40720&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40720&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40720&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40720&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40720&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40720&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40720&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40720&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40720&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40720&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40720&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40720&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40720&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40720&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40720&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40720&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40720&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40720&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40720&r=mysqlcfg

Reply via email to