Re: too much memory use!
- Posted by Jiri Babor <jbabor at PARADISE.NET.NZ> Feb 20, 2002
- 505 views
Kat, try the following quick fix instead of your strtok code. Let me know if it's any better, I have not got big enough text files to test it. jiri constant false = 0, true = 1 sequence data,word atom t integer c,f,inword data = {} word = {} inword = false -- flag f = open("kat1.eml", "rb") c = getc(f) while c != -1 do if find(c, {32,13,10}) then if inword then data = append(data, word) inword = false word = {} end if else inword = true word &= c end if c = getc(f) end while close(f) if inword then -- flush data = append(data, word) end if ----- Original Message ----- From: "Kat" <gertie at PELL.NET> To: "EUforum" <EUforum at topica.com> Sent: Wednesday, February 20, 2002 6:17 PM Subject: too much memory use! > > Eu took 29 minutes, 36 sec to execute the following program, and used > 142.7Megs of memory. The file it was reading is 12.1 megabytes. > > data = {} > datafile = open(data_noun,"u") > readline = gets(datafile) -- get a line > while not atom(readline) do > while find(readline[length(readline)],{10,13,32}) do readline = > readline[1..length(readline)-1] end while > junk_s = parse(readline,32) > data = data & {junk_s} > readline = gets(datafile) -- get another line > end while > close(datafile) > trace(1) -- to hold the program while getting memory use data > abort(0) > > What am i doing that runs a 12meg file up to 142.7megabytes? and takes > 1/2 hour to do it? > > How can i say data = glom(file) ? > > Kat > > > >