# Is it normal to be kicked out of irb?

**URL:** <https://www.ruby-forum.com/t/is-it-normal-to-be-kicked-out-of-irb/142072>\
**Category:** Ruby\
**Created:** [July 3, 2008, 6:18am UTC](https://www.ruby-forum.com/t/is-it-normal-to-be-kicked-out-of-irb/142072 "2008-07-03T06:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmanueloga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@emmanueloga](https://www.ruby-forum.com/u/emmanueloga)\
**Post date:** [July 3, 2008, 6:18am UTC](https://www.ruby-forum.com/t/is-it-normal-to-be-kicked-out-of-irb/142072/1 "2008-07-03T06:18:12Z")

</div>

Is it normal to be kicked off of irb when a Fatal error occurs ? I was  
kicked of of it while testing this (kicked off != code halt with an  
exception):

$ irb  
irb(main):001:0\> def is\_prime?(n); (“1” \* n) !~ /^1?$|^(11+?)\1+$/ ;  
rescue NoMemoryError; puts “ouch”; end  
=\> nil  
irb(main):002:0\> is\_prime?(2)  
=\> true  
irb(main):005:0\> is\_prime?(100000000)  
ouch  
=\> nil  
irb(main):006:0\> is\_prime?(1000000000)  
[FATAL] failed to allocate memory  
$

p.s.: is\_prime? method taken from  
[http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/](http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/)

---

<div class="post-metadata">

**Author:** ![emmanueloga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@emmanueloga](https://www.ruby-forum.com/u/emmanueloga)\
**Post date:** [July 3, 2008, 12:35pm UTC](https://www.ruby-forum.com/t/is-it-normal-to-be-kicked-out-of-irb/142072/2 "2008-07-03T12:35:20Z")

</div>

On Thu, Jul 3, 2008 at 6:15 AM, Emmanuel O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> irb(main):005:0\> is\_prime?(100000000)

It does not surprise me that IRB exits ungracefully in that case. BTW  
it does not surprise me either that the backtracking regular  
expression runs out of memory for such large numbers even if they are  
even ;).

Cheers  
Robert

–  
[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

AALST (n.) One who changes his name to be further to the front  
D.Adams; The Meaning of LIFF
