How do you safely handle ALLOC, ALLOC_N et al?

What happens when ALLOC and ALLOC_N fails? Is an Ruby exception raised?

I tried tracing the source code, and there seem to be some exceptions
being raised, but do they terminate Ruby completely? And how does that
work when Ruby is being used embedded within an application? (SketchUp
in this instance)

Anyone got a best practice example of how to handle ALLOC functions. Do
you validate the result etc?

And once something is allocated via ALLOC_N, and something later raises
an exception - does memory leak? Any way to catch this an ensure the
memory is freed?

···

--
Posted via http://www.ruby-forum.com/.

i did:

a = []; loop { a << rand }

and after a few time i get:

NoMemoryError: failed to allocate memory

and no, in irb ruby is not terminated

···

--
Posted via http://www.ruby-forum.com/.

I realise I forgot to mention that I was trying to determine how one
safely use ALLOC and ALLOC_N within the context of a C Extension.

···

--
Posted via http://www.ruby-forum.com/.

No one got any info on how to deal with ALLOC_N and errors/exceptions?

···

--
Posted via http://www.ruby-forum.com/.