ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> rubyonrails-talk
rubyonrails-talk
[Rails] Where does all the memory go?
by Kevin Evans other posts by this author
Aug 13 2007 7:35AM messages near this date
[Rails] Re: Existing Oracle schema with its own sequence | [Rails] Re: Where does all the memory go?
I've a method within an Event model..

  def batch_import(folder)
      require 'find'

      Find::find("#{SOURCE_PATH}/#{folder}") do |path|
          if path[-3..-1].downcase == 'jpg'
            @photo = Picture.new()
            @photo.data = File.new(path)
            @photo.filename = File.basename(path)
            @photo.caption = "none"
            self.pictures << @photo
            self.save
          end
      end
  end

Where Picture is ..

class Picture < FlexImage::Model
  file_store 'pictures'

  belongs_to :event, :counter_cache =>  true
  acts_as_list :scope =>  :event

  acts_as_solr :fields =>  [:caption]

end
 and Event is..

class Event < ActiveRecord::Base
  has_many :pictures, :order =>  'position',:dependent=>:destroy


When I run the code it uses a massive 1.5GB of memory to process 28
pictures. Ruby eventually returns the memory once you've browsed to
another view, but still?!?

Anyone have any ideas how/why?
should I be forcing garbage collection on @photo after each image?!?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Ta
lk" group.
To post to this group, send email to rubyonrails-talk@[...].com
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@[...].com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thread:
Kevin Evans
Bryan Duxbury
Kevin Evans
Bryan Duxbury
Kevin Evans
Rick Olson

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved