foreach() 'copies' $data, and it's the copy that isn't going away.

--Wez.

On 8/10/05, Ron Korving <[EMAIL PROTECTED]> wrote:
> "Derick Rethans" <[EMAIL PROTECTED]> schreef in bericht
> news:[EMAIL PROTECTED]
> > On Wed, 10 Aug 2005, Ron Korving wrote:
> >
> > > My situation is parsing a number of XML-reports. If parsing goes wrong
> in
> > > any way (XML parsing fails, XML validation fails, database insertion
> fails),
> > > I want to throw an exception. There's a script that batch-processes
> these
> > > files. I want to collect exceptions and give that feedback to the user.
> I
> > > wouldn't consider this bad practice myself (but of course, I'm not very
> > > objective in this situation).
> >
> > You can still clean up your memory before throwing the exception...
> 
> Actually, no. Even this shows the problem:
> 
>     foreach ($data as $line)
>     {
>       unset($data);
>       throw new Exception("error");
>     }
> 
> > > Even if I'm wrong about that, I'm not the only PHP-user and it's my
> humble
> > > opinion that the engine should be solid enough to deal with this.
> >
> > It's not easy at all, it would basically mean a full rewrite of the
> > engine's refcounting/garbage collection system, and also redoing all
> > extensions to use this mechanism. I think that's a bit too much to ask
> > just so that you don't get a leak if you're doing something 'weird'.
> 
> I never thought it would be easy. And I'm not saying it must be fixed. But I
> do think, more on the philosophical level as a programmer, that the engine
> "should" be able to deal with that situation.
> 
> Ron
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to