Re: out of memory, even tho remembered nothing!

new topic     » goto parent     » topic index » view thread      » older message » newer message
while 1 do  
  junk = gets(readfile)  
  size += length(junk) -- out of memory here, size = 9009698613  
  puts(1,sprintf("%d",size)&"\r")  
end while  

gets() returns an atom on EOF; since the check for this is missing, it keeps trying to read indefinately after the end of the file.

One thing strikes me as odd here- It keeps running because... length(-1) == 1; is this intentional? I thought it used to print something to the effect of "length of an atom is undefined" (which would have caught this bug).

The out of memory condition, though, definately sounds like an interpreter memory leak; memory is not being freed somewhere, either when the EOF error condition is hit in gets() or when the length() of an atom is read. Since the code forms an (unintentional) infinite loop, it eventually runs out of memory. To reproduce it (much) faster, just run this same code on an empty file.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu