Re: too much memory use!
- Posted by Kat <gertie at PELL.NET> Feb 19, 2002
- 512 views
On 20 Feb 2002, at 1:59, euman at bellsouth.net wrote: > > Hey Kat, > > lets see, your looking for these > > {10,13,32} or {Line Feed, Carriage Return, Space} > > right? > > What if you tried using find like this for starters: > > loc = find({10,13,32},readline[1..length(readline)]) > readline = readline[1..loc] How do you know which of {10,13,32} is returned? The first match? I don't know, but it's likely to be the 32, not the 10. > instead of: > > find(readline[length(readline)],{10,13,32}) > readline = readline[1..length(readline)-1] > > second, I have no idea what "parse" does > eg, junk_s = parse(readline,32) parse() is in strtok.e , in this case, it's breaking "1 2 3 4" into {"1","2","3","4"}. I need the bits later on, and it's better to break it once now than to break it repeatedly later. > third, you sure are making alot of sequence copy, > concat operations in this routine. > > finally, > > this is a bit strange coming from your caliber Kat. Not when coding at 1am till 3am ! > while find(readline[length(readline)],{10,13,32}) do > readline = readline[1..length(readline)-1] > end while > > your saying while I find this {10,13,32} at the end > of readline copy readline[1..to length(readline)]-1 > until I dont find it.....hmmmm Kat > > think about it! I did, i still don't see where the extra 80megs of memory is being used. Just gets()ing the file till -1, and adding it to data is using 60 megs of memory, altho it's fast, about 20 seconds. Even 60 megs sounds like a lot for a 12meg file, since 32bits per char is 48megs. I am now watching memory use scale up slowly while parse() is running after gets()ing the entire file first. I'd shut it down and change the code, but i already have 4 of those leftover virtual machines cluttering up memory, and i don't want to add more. Kat > Euman > euman at bellsouth.net > > Q: Are we monetarily insane? > A: YES > > ----- Original Message ----- > From: "Kat" <gertie at PELL.NET> > To: "EUforum" <EUforum at topica.com> > Sent: Wednesday, February 20, 2002 12:17 AM > 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 > > > > > > >