0

During a running task this exception is raised by the Curb gem (https://github.com/taf2/curb).

failed to allocate memory

It's strange because before the Exception the gem works properly (with others curl calls).

Any ideas?

I'm using Ruby 1.9.3 on Ubuntu server (and same error in dev mode locally - Mac OS X)

EDIT
In my task I do very much (+10k) calls like this

req = Curl::Easy.new do |curl| 
    curl.ssl_verify_peer = false
    curl.url = url
    curl.headers['Content-type'] = 'application/json'
end
req.perform
damoiser
  • 6,058
  • 3
  • 40
  • 66
  • How big is the file you are wanting to download? Also... why is it that you are needing to call something like your code example 10,000+ times? My guess is that your code is just using too much memory... :) Is there any way to use less calls in your code? – summea Apr 25 '13 at 17:41
  • @summea I don't think that is a problem of "weight" of the response, there are all pure-json-text (max 1k row of text ~ 30kb), and these are not stored: only read. Sadly I can't do less calls, every call is a request of a specific content – damoiser Apr 25 '13 at 17:44
  • Hmm; even if your called content is small, the fact that you are creating a new Curl object 10,000+ times would lead me to think that this is part of what is causing your memory issues.... Is there any way to combine your calls? – summea Apr 25 '13 at 17:46
  • @summea maybe re-using the Curl object for the others calls, but I don't know if works in this manner. In addition, in another task I use the same "Curl" procedure with no issues (even with "very much" calls). – damoiser Apr 25 '13 at 17:48
  • @summea maybe if possible I can deallocate manually the memory of the object, any idea how to do this? – damoiser Apr 25 '13 at 18:01
  • Hmm, well, before that, it might be a good idea to "profile" your code so that you can have a better view at what is going on with the memory usage :) There are probably other tools out there (and even a profiler included with Ruby itself...) but here is a nice profiler if you want to try it: http://ruby-prof.rubyforge.org/ – summea Apr 25 '13 at 18:06

0 Answers0