Forum: Ruby 'failed to allocate memory' with Mp3Info module

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0aba95393a71e4772769340e9052ecb2?d=identicon&s=25 firejdl (Guest)
on 2006-03-22 04:27
Hey all:

I'm pretty new to Ruby [this is my second script], but I'm trying to
write a little playlist generator script to scan a few directories every
once in a while [probably in a cron job], and update a .m3u playlist
based on what it finds. I like having info in my playlist so it loads
automatically with the playlist, so I'm trying to use the Mp3Info
module. I've got my list of files in an array called files. Here's the
code I'm using to test things out:

i = 0
files.each do |f|
  Mp3Info.open(f) do |info|
    puts f
    i += 1
  end
end

i is just to see how far it's getting, and puts f is just to see what
the particular song is.

It runs just fine, up to i=32. At that point, it errors out, with:
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:280:in
`read': failed to allocate memory (NoMemoryError)
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:280:in
`add_value_to_tag2'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:231:in
`read_id3v2_3_frames'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:220:in
`read_id3v2_3_frames'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info/id3v2.rb:135:in
`from_io'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info.rb:420:in
`parse_tags'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info.rb:179:in
`initialize'
        from
/usr/lib64/ruby/gems/1.8/gems/ruby-mp3info-0.5/lib/mp3info.rb:279:in
`open'
        from ./playlistgen.rb:48
        from ./playlistgen.rb:47

Am I doing things wrong? Or is it just running out of memory? If it's
the latter, is there any way to expand the amount of memory for
Ruby/Mp3Info to use?

All I really want to do is get the song length, artist and title...is
there any better way to do it?

Thanks!
~Joey

PS. I'm using Ruby 1.8.3 and Mp3Info 0.5 on AMD64 with the patch at
http://rubyforge.org/tracker/index.php?func=detail...
This topic is locked and can not be replied to.