Re: memory

new topic     » goto parent     » topic index » view thread      » older message » newer message

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? Is a new instance of data created every time
it
> is mentioned in the line?:
>
> puts(1,"removing 10 nulls\n")
> place = match({0,0,0,0,0,0,0,0,0,0},data)
> while place do
>  data = data[1..place] & data[place+10..length(data)]
>  place = match({0,0,0,0,0,0,0,0,0,0},data)
> end while
>
>
> Kat
>

Hello Kat,

Wouldn't be a better way to do the job this code?:

include file.e
include get.e
integer fn
fn = open("file.txt","rb")
integer char
sequence result
result = {}
while 1 do
    char = getc(fn)
    if char = -1 then exit -- EOF
    eslif char = 0  then -- ignore
    else result &= char -- append to the result
    end if
end while
close(fn)

Martin

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu