Re: out of memory, even tho remembered nothing!

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

What happens when you change the program to either of these two alternatives ...

Alternative #1

include std/filesys.e -- for move, del, create, dir  
include std/console.e -- any_key()  
  
atom size = 0  
  
with trace  
  
  
sequence readfilename = "E:\\YAGO\\yago2core_20120109\\using.tsv"  
puts(1,"filesize actually read in with gets()\n\n")  
  
 
object junk, junk1 , junk2 , junk3, readfile  
-- odd something else: winders says : 7.28 GB 7,823,038,472 bytes)  
-- when the app crashed, it printed out : size = 9009698613  
-- how would it read 1.5 Gbytes past the end of the file?  
  
readfile = open(readfilename,"rb")  
while 1 do  
  junk = gets(readfile)  
  size += length(junk) -- out of memory here, size = 9009698613  
  junk = 0 
  puts(1,sprintf("%d",size)&"\r")  
end while  
  
  
close(readfile)  
 
puts(1,"\nwell, if i got here, there was no crash!\n\n")  
any_key()  
  
abort(0)  

Alternative #2

include std/filesys.e -- for move, del, create, dir  
include std/console.e -- any_key()  
  
atom size = 0  
  
with trace  
  
  
sequence readfilename = "E:\\YAGO\\yago2core_20120109\\using.tsv"  
puts(1,"filesize actually read in with gets()\n\n")  
  
procedure do_it() 
object junk, junk1 , junk2 , junk3, readfile  
-- odd something else: winders says : 7.28 GB 7,823,038,472 bytes)  
-- when the app crashed, it printed out : size = 9009698613  
-- how would it read 1.5 Gbytes past the end of the file?  
  
readfile = open(readfilename,"rb")  
while 1 do  
  junk = gets(readfile)  
  size += length(junk) -- out of memory here, size = 9009698613  
  puts(1,sprintf("%d",size)&"\r")  
end while  
  
  
close(readfile)  
 
end procedure 
 
do_it() 
puts(1,"\nwell, if i got here, there was no crash!\n\n")  
any_key()  
  
abort(0)  
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu