On Apr 22, 2009, at 10:05, bdezonia / wisc.edu wrote:
> I am using Ruby 1.8.6-26 from the One Click Installer on Windows. I
> have a C extension that tries to calloc() memory. If the calloc()
> fails I call rb_raise(rb_eNoMemError,"Cannot allocate data"). My
> program is getting stuck in this code. Debugging (unfortunately via
> print statements) I can see that rb_raise() is going to be called.
> After that the exception is never caught by the outermost rescue loop.
> The program just stops doing anything (0% cpu) except it keeps
> updating a timer in another thread. Are there things I need to know
> about rb_raise() and how to use it?

If ruby is out of memory how could it allocate more memory to raise an  
exception?

Ruby itself allocates a NoMemError at startup to ensure it can raise  
one when it runs out of memory.  You'll probably need to do the same.   
See gc.c rb_memerror().