Reading files and memory
MisterX
x at monsieurx.com
Sat Jul 5 13:00:02 EDT 2003
Greg,
First, writing to file is more demanding than just reading.
However writing will be less affected IMOHO by buffers.
Normally, you know that if you can write a file, the
memory used by that file hasn't busted your PC with Out
of memory "issues". So the faster you write the better
but there should be little if any penalty in this case.
Naturally a certain buffer value will be "faster" depending
on how many writes you do... The condition is "how many times".
Consider that when you read, you might not be aware of the file
size. Although it's better to do read first and then parse later,
this may not be an option due to this memory problem.
On the other hand, writing, will be mostly affected if you write
in chunks compared to writing at once. And doing things in between
each write, will slow you down. On the other hand if the data you
are outputing is of an unknown size larger than RAM, consider a
buffer to be a "safe" option. More so if you are distributing that
stack.
Hope that doesn't confuse you!
Here's a good example I just thought of... I made an MP3 player long
ago with MC. I even had the MP3 tag info built in. It was fine to
read the mp3 as one file but consider that I may have some MP3s that
are 200MB's large! Oops, small detail it is...
Good news is that you can read from a negative offset from the file
(where that info is located) and voila! Easy, faster, cleaner file
handling - just requires a bit more thinking and scripting!
> -----Original Message-----
> From: metacard-admin at lists.runrev.com
> [mailto:metacard-admin at lists.runrev.com]On Behalf Of Gregory Lypny
> Sent: Friday, 04 July, 2003 15:46
> To: metacard at lists.runrev.com
> Subject: Reading files and memory
>
>
> Hello Everyone,
>
> I recently learned from Xavier that using Open File for
> Read and the
> Read command places less demand on memory than Put url ("file:" etc...)
> because the latter reads the entire file into memory.
>
> Is the same true when writing data to a file? I mean, is
> it better to
> use
>
> Open File X for write
> Write etc.
> Close file X
>
> than
>
> Put stuff after url ("file:" & X) ?
>
> Regards,
>
> Greg
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>
More information about the metacard
mailing list