On Feb 15, 2007, at 14:39, Mischa Berger wrote:
> Hi everyone,
>
> Consider the following code:
>
> # Save the file on the file system
> File.open(self.temp_path, 'wb') do |f|
>   while buff = myfile_field.read(4096)
>     f.write(buff)
>     f.flush
>   end
> end
>
> Is there any benefit in flushing in the code above?

Unlikely.  It only ensures the data is written to the file.

> Does this mean 4096 bytes of memory are freed everytime flush is  
> called?

No.  The GC will clean up memory as necessary.

> I'm trying to grasp what exactly happens and if there are any benefits
> or drawbacks.

fflush(3) is called more often, that's all.