[plt-scheme] What happens if out of memory

From: Chihiro Kuraya (rxqvw at yahoo.co.jp)
Date: Sun Jun 12 05:50:36 EDT 2005

> Well, it's easy to try it out -- with 'fail-ok:
> 
> | Welcome to MzScheme version 299.106, Copyright (c) 2004-2005 PLT Scheme, Inc.
> | > (require 'foreign)
> | > (define a '())
> | > (set! a (cons (malloc 1000000000 'fail-ok) a))
> | > (set! a (cons (malloc 1000000000 'fail-ok) a))
> | > (set! a (cons (malloc 1000000000 'fail-ok) a))
> | out of memory 
> 
> ... so no value is returned, there is just an exception.  Without it:
> 
> | Welcome to MzScheme version 299.106, Copyright (c) 2004-2005 PLT Scheme, Inc.
> | > (require 'foreign)
> | > (define a '())
> | > (set! a (cons (malloc 1000000000) a))
> | > (set! a (cons (malloc 1000000000) a))
> | > (set! a (cons (malloc 1000000000) a))
> | GC Warning: Out of Memory!  Returning NIL!
> | > a
> | (#f #<cpointer> #<cpointer>)
> 
> ... malloc barfs and you get NULL.

Thank you very much for trying.

Yes, I can try it on some systems.
But I don't have all platforms MzScheme supports,
and even if I have them, it is not clear this behavior is
guaranteed to be unchanged in future.
So if this behavior is formal specification,
it would be better to explicitly write document like that.


Chihiro Kuraya
__________________________________
Save the earth
http://pr.mail.yahoo.co.jp/ondanka/



Posted on the users mailing list.