[plt-scheme] What happens if out of memory
On Jun 12, Chihiro Kuraya wrote:
>
> > 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.
AFAICT, it is not a formal specification -- the behavior of the
fail-ok version is specified and documented, and the behavior of other
allocations is unspecified therefore undocumented. (Matthew should
correct me if I'm wrong, but I think that this is the reason why it is
not documented.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!