ID: 16635 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Closed Bug Type: Unknown/Other Function Operating System: x86/Linux PHP Version: 4.2.0 Assigned To: sterling New Comment:
[EMAIL PROTECTED]: there is a leak when the call "fails" in this case. Please try copying this file into your local source: http://cvs.php.net/co.php/php4/ext/dio/dio.c?login=2&r=1.21&p=1 It should act as a drop-in replacement for ext/dio/dio.c. If you don't want to risk that, then look for PHP_FUNCTION(dio_read) in that file, and then these lines: res = read(f->fd, data, bytes); if (res <= 0) { efree(data); // <-- this line fixes the leak RETURN_NULL(); } Previous Comments: ------------------------------------------------------------------------ [2002-11-03 04:40:20] [EMAIL PROTECTED] I have the memory leaking problem with dio_read() as well. The PHP versio I use is 4.2.2 with DirectIO extension in an embedded Linux box. I have an X10 home automation software written with PHP and it runs as a daemon. The serial port is configured to be non-blocking. I check if there is any data available about 10 times a second (it's a busyloop with usleep(100000) in it). The checking is done as follows: $data=dio_read($fp,1); After running the daemon for about 20 hours, I always get the following error message: Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 2 bytes) in /mnt/data/plugins/X10/html/x10_wrapper.php on line 76 Line 76 is the one above with dio_read(). I would really need a fix for this or I'm forced to write a nasty kill-the-process-and-then-restart-it-again-just-to-make-it-stay-alive piece of script to be ran by cron. -Juha ------------------------------------------------------------------------ [2002-04-20 12:09:13] [EMAIL PROTECTED] Cannot reproduce - this shouldn't happen. ------------------------------------------------------------------------ [2002-04-18 19:12:30] [EMAIL PROTECTED] Assigned to Sterling who is the maintainer of this extension.. ------------------------------------------------------------------------ [2002-04-16 11:11:28] [EMAIL PROTECTED] I am using the RC4 of php4.2.0 with Apache/1.3.24 (Unix). Every time dio_read() is called in a script, the htttpd process uses more and more memory. ex.: $o = dio_read($fp,100000); would let httpd grow by ca. x times of 100000. unset($o) will not get the memory back. the httpd process would keep its size until the script terminates. Needing to call dio_read repeatidly makes it even worse. And using 1024 bytes blocks only slows the process of growing down. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16635&edit=1
