You’re getting that error because you’re running out of memory, the two code 
snippets you describe are not identical, the RSpec one creates more classes and 
objects under the hood, you should reduce the amount of specs you are trying to 
create at once or make more memory available to Ruby.

Hope that helps  

Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk


On Thursday, 23 February 2017 at 21:13, Satya Rao wrote:

> Hi Everybody,
>  I'm new to Rspec. I'm getting '[FATAL] failed to allocate memory' when I 
> loop through some it blocks over 500000 times. And when tried the same with 
> pure ruby I'm not getting the fatal error and the execution was successful. 
> Below is my code.
>  
> Rspec code:
>  
> fatal_error_check_spec.rb
> --------------------------------------
>  
> describe "fatal error check" do
> for i in 1 .. 500000
> it "Example it block 1" do
> puts "My first it"
> end
>  
> it "Example it block 2" do
> puts "My second it"
> end
> end  
> end
>  
>  
>  
>  
> When running the above rspec code  gives me an above fatal error after ~4 
> mins without running anything.
>  
>  
> Pure Ruby code:
>  
> fatal_error_check.rb
> -----------------------------
>  
> for i in 1 .. 500000
> puts "My first it"
> puts "My second it"
> end
>  
>  
> When running this ruby code, I didn't get any error and printed those two 
> puts statements 5 lack times successfully.
>  
>  
> Please help me with solving the above fatal error issue with Rspec. What 
> should I do to fix this error.
>  
>  
> My system env is as follows:
> -----------------------------------------
> Windows 7 PC qith 8GB RAM
> Ruby version: 1.9.3
> rspec (3.5.0)
>  
>  
> Please help me to fix this issue.
>  
>  
> Thanks,
> Satya.
>  
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/c2824e72-abb7-4374-b2a9-7137acad9aea%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/rspec/c2824e72-abb7-4374-b2a9-7137acad9aea%40googlegroups.com?utm_medium=email&utm_source=footer).
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/164FB5F9B64F49068E01C9B16FFDF966%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to