Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6766701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:51:46+00:00 2026-05-26T14:51:46+00:00

I made a very big script to feel my initial datas into my rails

  • 0

I made a very big script to feel my initial datas into my rails app. I have about 3000 lines in my CSV and 10000 images.

After maybe 300 upload i got this message :

/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``': Cannot allocate memory - identify -format %wx%h '/tmp/stream20111104-14788-1hsumv7.jpg[0]' (Errno::ENOMEM)

My upload script :

if (row[28] != nil)
   hotelalbum = HotelAlbumPhoto.find_or_create_by_title(h.title)
   hotelalbum.description = "Album photo de l'hotel " + h.title.capitalize
   hotelalbum.hotel_id = h.id
   hotelalbum.save

   files =  Dir.glob('IMAGES/' + row[28].gsub(/\\/,'/') + '/*.jpg')
   i =0
   for file in files
      i += 1
      photopath = File.expand_path('../../import', __FILE__) + '/' + file
      photoname = file.split('/').last
      if (i==1)
        hotelalbum.thumbnail = open(photopath)
        hotelalbum.save
      end
      if (i==1)
        h.thumbnail = open(photopath)
      end
      photo = HotelImage.find_or_create_by_image_file_name_and_hotel_album_photo_id(photoname,hotelalbum.id)
      if (photo.image_file_size == nil || photo.image_file_name != photoname)
          photo.image = open(photopath)
          photo.activated = true
          photo.alt = "Photo de l'hotel " + h.title
          photo.save
      else
         puts photopath + ' already updated'
      end
   end
end

When i check my memory with top command, i see ruby process use more memory on each upload. How can i manage this?

Thank you for help

ps : My server is a virtual machine with 512Mb memory, one solution is to inscrease this memory but i hope to find an other.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:51:47+00:00Added an answer on May 26, 2026 at 2:51 pm

    I don’t know where the open function is defined, but I’m suspicious that I don’t see a corresponding close…

    update Better idea, change photo.image = open(photopath) to photo.image = File.read(photopath)

    According to the docs, read:

    Opens the file, optionally seeks to the given offset, then 
    returns length bytes (defaulting to the rest of the file). 
    read ensures the file is closed before returning.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a very simple AppleScript to close tabs in Safari. The problem
in my application I made a very simple binding. I have a NSMutableArray bound
We have a number of very old data entry forms that were made in
I am a very new programmer, I have made a couple basic applications, however
I have made a very simple Pie Graph generator using Javascript & SVG graphics.
I have a very big table with many columns. Values in some of the
I have always been a very big fan of the DHTML calendar http://www.dynarch.com/projects/calendar/ I
I have an application that send very big quantity of requests to the server
I have a table that isn't going to get very big and contains the
I made a data.frame in R that is not very big, but it takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.