Re: [PHP-DEV] PHP4: php_module holds memory to long !
Any ideas ? Welcome to Unix. You can only increase the heap size using sbrk(), you cannot shrink it. So, if you have allocated n bytes, you can only reuse those bytes, but never give it back to the system (without terminating the process). - Sascha Really? From AIX docco... "The sbrk subroutine adds to the break value the number of bytes contained in the Increment parameter and changes the amount of available space accordingly. The Increment parameter can be a negative number, in which case the amount of available space is decreased." Bill -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] PHP4: php_module holds memory to long !
On Wed, Jan 10, 2001 at 09:23:43PM +0200, Stanislav Malyshev wrote: SS Thanks for the correction! I have never seen that in action SS though. Usually, the C library will keep freed memory in SS free lists and does not decrease the size of the data SS segment using sbrk. Actually, from glibc source there's a hook that is supposed to do this in some circumstances. Never could actually make it work in real life. Also, IIRC glibc on Linux allocates really large (8k+? 16k+?) blocks as mmap's of /dev/zero and those are really given back to system, since on free they are just munmap'ed. Checked the glibc 2.2 sources, looks like 128k+ blocks are mmap'ed and given back to the system. How does Zend allocate memory then? I guess I could try to figure it out myself, but it's a bit complex. Are there many small chunks? Seems like emalloc() is called a lot creating small chunks, but each emalloc() doesn't result in a corresponding malloc() perhaps? I guess with glibc on Linux it would be nice if malloc() allocated say 128k chunks, and emalloc() used memory inside those. Stig -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] PHP4: php_module holds memory to long !
The answer is really not so easy. I have RedHat Linux 6.2 (with standard kernel, I suppose 2.1). I tried such program in c++: //File mall.cc #include alloc.h #include stdio.h #include stdlib.h #include unistd.h int main() { void* v[1000]; for (int i=0;i1000;i++) { v[i]=malloc(10); //printf("%i. %p; ",i,v[i]); memset(v[i],i,1); } printf("\n\nMemory allocated. Wait 20 s.\n"); sleep(20); for (int i=0;i1000;i++) { free(v[i]); //printf("%i. ^; ",i,v[i]); } printf("\nMemory freed. Wait 20 s.\n"); sleep(20); } Then I examine it with 'top' command (then shift-M to sort by memory usage). In first 20 seconds process 'mall' is on the top with 13M, then in next 20 s it is NOT. And here is the basic difference between 'mall' and 'httpd' processes: the last are on the top ALL THE TIME. So ? -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]