On Mon, Mar 10, 2008 at 7:43 AM, Jonathan Mast
<[EMAIL PROTECTED]> wrote:

>  What benefit does flushing have?  Would it help prevent memory
> leaks as per the above scenario or what?

Flushing gets the data out right away, in case there's anybody waiting
for it. In the case of log files, it means that the person debugging
the long-running program gets to see the up-to-date log. It also means
that a program that suffers a serious fault (such as running out of
memory, or an uncaught signal) won't be so likely to die with the last
few lines of the log still unwritten -- and those last few lines are
probably trying to tell you something important, since the program
just crashed.

As for memory leaks, if we learned that technique X were necessary to
prevent memory leaks in Perl release Y, we would track down the leak
so that technique X is no longer needed in the next release. The
exception is if Perl's architecture prevents us from stopping the
leak; then we document it.

The primary cause of memory leaks in Perl code is circular references,
in which a programmer has (intentionally or not) built a ring-shaped
data structure out of (non-weak) references. It is important to break
all such rings when data structures are to be discarded, else their
memory can't be reclaimed before the program quits. This is rarely a
problem for most programmers, though, since ring-shaped data
structures are hardly ever needed in Perl; hashes and arrays are more
convenient ways to work with most data.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to