# Newbie question - failed to allocate memory

**URL:** <https://www.ruby-forum.com/t/newbie-question-failed-to-allocate-memory/186041>\
**Category:** Rails\
**Created:** [March 30, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/newbie-question-failed-to-allocate-memory/186041 "2010-03-30T19:39:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jman1977](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jman1977](https://www.ruby-forum.com/u/jman1977)\
**Post date:** [March 30, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/newbie-question-failed-to-allocate-memory/186041/1 "2010-03-30T19:39:47Z")

</div>

Hi,

I am pretty new in Ruby and Rails programming. I am trying to simply  
output data of a really large table with many columns (around 30  
columns) in an XML document using erb. I am able to loop through all the  
records and output 2 columns. But when I add the following code to  
output all the fields of every record the memory usage goes up a lot and  
I get a failed to allocate memory error. Any idea why? Should I flush  
the buffer? Should I disable the cache? Please help.

\<% @records.each do |a| -%\>  
\<% RecordClass.columns\_hash.each do |key,value| -%\>  
\<%= a[key] -%\>  
\<% end -%\>  
\<% end %\>

Thanks in advance.
