RMagick: UnableToConcatenateString `

I have a program to generate my website bluebottleimages.org

It creates thumbnails using Rmagick. I run the program (on the server),
and it goes for a while, but then I get

RMagick: UnableToConcatenateString `
'.
Warning: recursive semaphore lock detected!

and it’s stopped there.

It has come up invariably at the same spot, so I thought it was
corrupted image files, but even after replacing them I get the error
message. Now I’m thinking that it’s probably just that I’m over-using
server resources making all those thumbnails… Do you think that’s
the case, or is it more likely that there’s a problem with my program?

If you like I can post my code.

Jonathan D. wrote:

and it’s stopped there.

It has come up invariably at the same spot, so I thought it was
corrupted image files, but even after replacing them I get the error
message. Now I’m thinking that it’s probably just that I’m over-using
server resources making all those thumbnails… Do you think that’s
the case, or is it more likely that there’s a problem with my program?

If you like I can post my code.

Try adding a periodic call to GC.start to your program. See this note:
http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618

Tim H. wrote:

Try adding a periodic call to GC.start to your program. See this note:
http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618

Thanks! It works perfectly now

Tim H. wrote:

used by individual image objects with the Magick::Image#destroy! method,
thus eliminating the need to call GC.start from time to time.

Seems like ruby could help out libraries like RMagick by exposing an API
to tell GC that memory has been allocated by something other than ruby’s
malloc. Did anyone ever pursue that?

Jonathan D. wrote:

Tim H. wrote:

Try adding a periodic call to GC.start to your program. See this note:
http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618

Thanks! It works perfectly now

Good news!

Looking forward, starting with RMagick 2.0.0 you can free the memory
used by individual image objects with the Magick::Image#destroy! method,
thus eliminating the need to call GC.start from time to time.

Joel VanderWerf wrote:

Tim H. wrote:

used by individual image objects with the Magick::Image#destroy! method,
thus eliminating the need to call GC.start from time to time.

Seems like ruby could help out libraries like RMagick by exposing an API
to tell GC that memory has been allocated by something other than ruby’s
malloc. Did anyone ever pursue that?

This may help in the general case but for RMagick not so much. RMagick
doesn’t know how much memory ImageMagick is allocating for an image.
Even if it knew or could compute the amount of the initial allocation
the amount of memory used for an image can vary over the lifetime of the
image. I suppose RMagick could give Ruby an estimate, which might help
some.

I gave some thought to trying to get ImageMagick to use Ruby’s memory
management API. It seems like it might solve the problem, but I’m not
sure that the IM developers would want to devote that much effort to
Ruby users.

Adding #destroy! is something I could do on my own. It more-or-less
parallels the way you can close files and sockets and otherwise free up
resources that Ruby either doesn’t know about or might let hang around
longer than necessary.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs