#36197 [Bgs->Opn]: php does not free script memory when the process alive
| From: | momo@php.net | Date: | Thu, 02 Feb 2006 08:19:22 +0000 |
| Subject: | #36197 [Bgs->Opn]: php does not free script memory when the process alive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92812@lists.php.net to get a copy of this message | ||
ID: 36197
User updated by: momo@php.net
Reported By: momo@php.net
-Status: Bogus
+Status: Open
Bug Type: Apache related
Operating System: gentoo 2005.1
PHP Version: 5.1.2
New Comment:
Thank for the replay, but please read my question carefully.
I know that php free the allocated by emalloc memory on the end of
script, my question was why php don't do it for the memory that was
allocated by the *php end user* just like the example i give above.
Yes you can call it feature, and blame linux mm, but the fact that php
do it for the memory used by the extensions developers, give me a hint
that may there is simple way protecting the end user to not kill his
server as well, especially when we talk about linux+apache 1.3.x that
AFAIK it the most common configuration of production php web servers.
(sorry for opening the bug again, if you will change the status of the
bug to 'will not fix', i'll let him die)
Previous Comments:
------------------------------------------------------------------------
[2006-01-31 16:12:08] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
PHP uses an internal memory memory manager, when you allocate memory
using emalloc() it'll be freed at the end of the request, even if you
don't free it explicitly yourself.
------------------------------------------------------------------------
[2006-01-30 12:24:33] momo@php.net
My apology of being nagger but the bellow code, use memory (even
without inner free) that become free right after the script execution
ending. is there a problem to get back the php varibles memory, just
like the efree do?
PHP_FUNCTION(momo_test)
{
char *some_memory;
int a;
some_memory = (char *) emalloc(0x4000000);
for(a=0;a<0x4000000;a++) some_memory[a]=0;
//efree(some_memory);
}
Can you send me more exact reference how the linux memory allocation
responsible for this spend memory?
------------------------------------------------------------------------
[2006-01-29 16:07:05] sniper@php.net
Expected behaviour. Search more information how memory allocation and
freeing works in Linux from the web..and also 'man ps'
------------------------------------------------------------------------
[2006-01-29 09:08:18] momo@php.net
Description:
------------
while playing with big arrays, i see that memory that was used on php
with apache 1.3 sapi doesn't became free till the next time apache use
*the same* process. here how the memory looks like *after* the scripts
have finish to run:
momo@(none) htdocs # ps -A v|grep http
27677 ? Ss 0:00 0 4188 8875 4532 0.8
/www5/bin/httpd
27679 ? S 0:00 0 4188 8875 3072 0.5
/www5/bin/httpd
27680 ? S 0:03 1 4188 31759 26580 5.1
/www5/bin/httpd
27681 ? S 0:00 0 4188 54019 48740 9.4
/www5/bin/httpd
27682 ? S 0:00 0 4188 8875 2532 0.4
/www5/bin/httpd
27683 ? S 0:00 0 4188 8875 2536 0.4
/www5/bin/httpd
27716 ? S 0:00 0 4188 8875 2536 0.4
/www5/bin/httpd
27764 pts/0 R+ 0:00 0 57 1406 436 0.0 grep http
Reproduce code:
---------------
for($a=0;$a<1024*512;$a++) {
$ret[] = 1.1;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36197&edit=1