RE: [PHP] huge memory usage in PHP 4.0.2 object programming?
| From: | Vincent W.S. Tam | Date: | Sun, 17 Sep 2000 05:33:30 +0000 |
| Subject: | RE: [PHP] huge memory usage in PHP 4.0.2 object programming? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-17057@lists.php.net to get a copy of this message | ||
Hi Mark!
Thanks for your reply! However The 70M memory usage is the RSS!
I run the test a few more times with loading 1000, 1000 and 2000 records in
different time frames (around 15mins between them), I started to hear the
sound of my disk trashing for swap in the 3rd run.
1) here's the result of "ps aux" for the apache processes, I allow 3 apache
processes
to listen to client connections.
USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND
nobody 30524 0.0 20.0 34168 25652 ? S Sep 16 0:51
/usr/local/apache/bin
nobody 30525 0.1 43.6 58220 55740 ? S Sep 16 1:31
/usr/local/apache/bin
nobody 30534 0.0 20.0 33944 25596 ? S Sep 16 0:45
/usr/local/apache/bin
2) the result of "free", note the 24M swap usage
total used free shared buffers cached
Mem: 127760 126640 1120 20444 384 6312
-/+ buffers/cache: 119944 7816
Swap: 130748 24948 105800
I hope there is some other ways to fix it!? (Don't write object in PHP?)
Thanks!
Vincent
-----Original Message-----
From: Mark Charette [mailto:charette@sneezy.org]
Sent: Sunday, September 17, 2000 5:42 AM
To: vincent@aib.net; php-general@lists.php.net
Subject: Re: [PHP] huge memory usage in PHP 4.0.2 object programming?
This has nothing to do with Apache or PHP if you're running on Unix, but is
the way the memory allocation system on Unix runs. Freeing memory allocated
via malloc() (using the free() call) does not release memory back to the OS,
rather it marks the memory as "free for re-use". (We won't get in to
anonymous mmap'ing and use the sbrk() call - we'll leave that as an exercise
for our students :^)
If you look at the RSS of the execution programs you will most probably
notice that it is much smaller than 70 Mb after you do that manipulation
that involves a 70 Mb data area. RSS is more what you care about, not the
program size, especially if your OS supports lazy allocation.
----- Original Message -----
From: <vincent@aib.net>
To: <php-general@lists.php.net>
Sent: Friday, September 15, 2000 11:53 PM
Subject: [PHP] huge memory usage in PHP 4.0.2 object programming?
> Hello,
>
> I'm writting a program using PHP4's object feature. However after each run
I found that the apache process hold up
> 70M of the memory!!! In the 2nd run however it doesn't make the apache
process grow to 140M, remain 70M.
>
> The program read 2000 records into 2000 objects from a mysql database and
do some processing to produce another
> 2000 objects for later use (It hasn't finish). Is PHP4 will not release
memory for objects, or rather this is an apache problem?
> I add unset() to the final produced objects seems still doens't free up
the memory after the run.
>
>
> Thanks for your help! Please reply a copy to my e-mail if possible!
> Vincent
>
> ========================================================
> Brief of the enviornment:
> - Debian 2.1 with Linux kernel 2.0.38
> - Apache 1.3.12 with PHP 4.0.2 running as a apache static module
> - PHPLib 7.2b used in db object
>
> Main object types:
> - db object: read records from mysql database
> - object A: source object type
> - object B: destination object type
> - factory object: translate object A to object B
>
> Brief of the program:
> 1) db object reads 2000 object A from a mysql database and put them into
an array inside the factory object.
> 2) the factory object produce 2000 object B use the 2000 object A from the
array.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>