Bug #854 Updated: include() problem

From: Date: Sat, 17 Oct 1998 11:09:49 +0000
Subject: Bug #854 Updated: include() problem
Groups: php.dev 
Request: Send a blank email to php-dev+get-1860@lists.php.net to get a copy of this message
ID: 854 Updated by: zeev Reported By: matt@debris.com Status: Closed Bug Type: Reproduceable crash Assigned To: Comments: Ok, at last, I'm at your help :) I've reproduced the problem on your box. I also fixed it. Basically, at a certain point, the script runs out of memory, or actually, it can't find a sufficiently big memory block. Since PHP doesn't handle out of memory errors (we never got around to it) - the script crashed. Using include() within a loop is *VERY* bad practice, since it 'leaks' memory. That is, memory is allocated separately for each include file, and is NEVER freed until the end of the script execution. In your case, you should really consider one of the following alternatives: 1. Define a function that does what the include file does, and call that function instead of repeatedly including the include file. 2. Use require() instead. require() only parses the include file once, and allcoates memory for it once. As far as proper coding is concerned, (1) is much much better. I'll make sure we handle out of memory errors nicely in 3.0.6, but that won't solve your problem - since all I'm planning to do is exit(), instead of the current situation which may crash under some circumstances. Full Bug description available at: http://ca.php.net/bugs.php3?id=854 -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1860) next »