Re: memory
- Posted by euphoria at carlw.legend.uk.com Jul 13, 2001
- 397 views
Kat wrote: > On 12 Jul 2001, at 19:04, martin.stachon at worldonline.cz wrote: > > > > Kat writes : > > > Hey all,, > > > > > > I have a short program that opens a 6.8megabyte file, containing text > > > separated by lots of {0}. The object is to eliminate the {zero}s, and > > > reformat the results to a more text-looking file. What i can't figure > > > is that Taskinfo says Eu is using 86Megabytes in memory to do it! > > > > > > Are these the lines doing it? [snip Kat's code that processes a block at a time] > > Hello Kat, > > > > Wouldn't be a better way to do the job this code?: [snip Martin's code that processes a byte at a time] > That way makes 6.8 million file accesses. Actually it's more like 850 file accesses. Euphoria has a built in 8k buffer. A couple of years ago I made a suggestion (on the old mailing list) for Rob C. to make the buffer size variable. He provided a few good reasons why he [w|c|sh]ouldn't do it, none of which I can remember right now... ;-| > I'd still like to know why it wanted so much memory for a little 6.8meg text > file. Euphoria stores bytes from a file as integers. Integers take up 4 bytes of memory apiece. So, excluding sequence overheads, a 6.8Mb file takes up 27.2Mb of memory. To make matters worse, operating on that sequence without considering the inner workings of Euphoria could double, triple or even quadruple the amount of memory needed - entirely consistent with the 86Mb you mentioned earlier in the thread. HTH, Carl -- Carl R White - aka - Cyrek eMail: carlw at legend.co.uk cyrek at bigfoot.com URL: nope none nada zip