memory leak in Python 2.1/FreeBSD? [was Re: Garbage collection on strike?]

Robin Becker robin at
Thu May 17 09:47:29 CEST 2001

In article <Pine.LNX.4.33.0105170003030.912-100000 at C800000-A.potlnd1.or.>, greg jorgensen <greg at> writes
>The suspect code is a loop:
>  f = open('filename', 'rb')
>  while 1:
>      buf =
>      if not buf: break
>      # buf is sent over open ftp connection
>      conn.send(buf)
>(It's an overriden version of ftplib.FTP.storbinary that writes a '#' to
>stdout for each block transferred).
The return of an empty buffer may happen for reasons other than EOF
especially on traditional UN*X systems. Typically some signal other than
the expected one occurs and pre-empts the I/O signal. Looking in the
fileobject.c source code it seems that this certainly is allowed for.

>Any ideas on why this works on my Linux box (128 megs of RAM) but fails
>reliably in the same place on the FreeBSD box (64 megs)?
>Greg Jorgensen
>gregj at

Robin Becker

More information about the Python-list mailing list