Java::JavaLang::OutOfMemoryError using Builder

I’m getting a Java::JavaLang::OutOfMemoryError (GC overhead limit
exceeded) error in a Rails app that selects a about 40 rows from a
database, orders them descending and uses builder to create an atom feed
of the result.

It works fine on 5 to 10 rows, but anything above that causes Webrick to
grind for about a minute or so and then cough up this error.

The offending code is:

in projects_controller.rb:

def feed
@title = “RSAC Recent Project Accomplishments”
if params[:program_area].nil?
@projects = Project.order(“updated_at desc”)
else
@projects = Project.where(:program =>
params[:program_area]).order(“updated_at desc”)
end
@updated = @projects.first.updated_at unless @projects.empty?

respond_to do |format|
  format.atom { render :layout => false}
  format.rss { redirect_to feed_path(:format => :atom), status =>

:moved_permanently }
end
end

in feed.atom.builder view:

atom_feed :language => ‘en-US’ do |feed|
feed.title @title
feed.updated @updated

@projects.each do |item|
next if item.updated_at.blank?

feed.entry( item ) do |entry|
  entry.url project_url(item)
  entry.title item.name
  entry.content item.summary, item.accomplishments.last.milestone,

:type => ‘html’

  # For Google Reader.
  entry.updated(item.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ"))

  entry.author do |author|
    author.name entry.leadName
  end
end

end
end

This shouldn’t be working this hard, right?

-Jim