Page 1 of 2

Catastrophic failure

Posted: 2011-03-08T12:09:43-07:00
by oksanen
I get repeatable failure in imagemagick object in Windows XP. I am running following script:

Code: Select all

Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
do while true
   n=n+1
   jpeg="20110308-070845UTC.jpg"
   timestamp="'"+cstr(n)+"'"
   msgs = img.Convert(jpeg,"-font=C:\Windows\fonts\arial.ttf","-rotate=-90", "-gravity=south", "-stroke='#000C'", "-strokewidth=2", "-pointsize=20", "-draw=text 0,5 "+timestamp, "-fill=yellow", "-stroke=none", "-draw=text 0,5 "+timestamp, "imagemagick_test.jpg")
loop
The conversion fails after 3982 or so calls with following error message:

Code: Select all

C:\Documents and Settings\Sirius\My Documents\canon\imagemagick_test.vbs(7, 4)
(null): Catastrophic failure
Is there any fix or workaround to this available? This is a part of automated program that takes images every five minutes and labels them with Imagemagick. All goes well for about ten days and then the script fails with this error. In my test run I converted the same image in a loop and it fails every time around 3980 cycles. I can supply the source image and the wbscript code if someone wants to try.

The version is 6.6.7-1 Q16.

best regards,

arto

Re: Catastrophic failure

Posted: 2011-03-08T14:27:36-07:00
by el_supremo
I'm not familiar with using IM and VB but I'd say that the problem is that you aren't destroying the ImageObject each time around the loop. I suspect that the image object is growing larger by one image on each pass through the loop until you run out of ram.
Your loop should look something like this:

Code: Select all

Dim img

do while true
   Set img = CreateObject("ImageMagickObject.MagickImage.1")
   n=n+1
   jpeg="20110308-070845UTC.jpg"
   timestamp="'"+cstr(n)+"'"
   msgs = img.Convert(jpeg,"-font=C:\Windows\fonts\arial.ttf","-rotate=-90", "-gravity=south", "-stroke='#000C'", "-strokewidth=2", "-pointsize=20", "-draw=text 0,5 "+timestamp, "-fill=yellow", "-stroke=none", "-draw=text 0,5 "+timestamp, "imagemagick_test.jpg")

>>>Destroy the image object here - I don't know the specific syntax for it
loop
Pete

Re: Catastrophic failure

Posted: 2011-03-08T22:47:28-07:00
by oksanen
el_supremo wrote:I'm not familiar with using IM and VB but I'd say that the problem is that you aren't destroying the ImageObject each time around the loop. I suspect that the image object is growing larger by one image on each pass through the loop until you run out of ram.

Pete
Thanks Pete! This is a good suggestion. But unfortunately it makes no difference. The imagemagick object breaks about the same time even if I destroy and re-create the object in the loop. It is rather strange why this happens.

There is some memory leak, but it is very small. The process takes in the beginning (after the first loop) about 10 000 Kb of memory and at the end about 12 000 kb.

arto

Re: Catastrophic failure

Posted: 2011-03-08T23:05:02-07:00
by anthony
I am not a VB or windows programmer, but I do have a couple of suggestions..

First IM will delay reading in some things like configuration files until it needs them.
As such teh 'type.xml' for fonts or 'colors.xml' for colornames to RGB valuse will not be read in until needed. As such teh first time though the loop may show some memory increase. However larger runs should not show any other increases if everything is removed and destroyed properly.

Of course some languages (I do not know if VB is included in this) have a very lasy garbage collection making this harder.

One suggestion however is to do a 'fake' run with less options and see if you can track down exactly what option is causing the memory leak.

Re: Catastrophic failure

Posted: 2011-03-09T14:26:47-07:00
by oksanen
anthony wrote:One suggestion however is to do a 'fake' run with less options and see if you can track down exactly what option is causing the memory leak.
Hello Anthony!

Good suggestion. I tried to remove as many options as possible and still get the error. The simplest I could get was this:

Code: Select all

msgs = img.Convert("20110308-070845UTC.jpg","-draw=text 0,5 '12345'", "-draw=text 0,5 '12345'", "test.jpg")
This failed after 13350 cycles. If there was only one draw command the script did not fail (or at least not before 40000 cycles).

arto

Re: Catastrophic failure

Posted: 2011-03-17T23:29:12-07:00
by oksanen
Any help with this one? Another Catastrophic failure occured last night and 5 hours of images were lost.

arto

Re: Catastrophic failure

Posted: 2011-09-12T23:12:16-07:00
by oksanen
Any progress with this? Just a friendly remainder after another crash (and lost images) last night.

arto

Re: Catastrophic failure

Posted: 2011-09-15T18:59:15-07:00
by magick
Stand by... we're investigating the issue.

Re: Catastrophic failure

Posted: 2011-09-16T11:53:12-07:00
by magick
We cannot reproduce your problem. We're using ImageMagick 6.7.2-6, the current release. You VBS script has iterated over 50000 times now without complaint.

Re: Catastrophic failure

Posted: 2011-09-17T00:31:04-07:00
by oksanen
very good. I will update and run the tests again.

arto

Re: Catastrophic failure

Posted: 2011-09-17T08:05:00-07:00
by oksanen
I upgraded to ImageMagick-6.7.2-6-Q16-windows-dll.exe

The new test code using "logo:" as the input file.

Code: Select all

Const ERROR_SUCCESS = 0
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
dim msgs,n
n=0
do while true
  n=n+1
  wscript.echo n
  msgs = img.Convert("logo:","-draw=text 0,5 '12345'", "-draw=text 0,5 '12345'", "imagemagick_test.jpg")
  If Err.Number <> ERROR_SUCCESS Then wscript.echo Err.Number & ": " & Err.Description & vbCrLf
  WScript.Sleep 10
loop
Unfortunatelly the program still fails, now every time after 21429 cycles. I ran the test on two computers with similar results.

C:\Documents and Settings\Digistar3\My Documents\arto> cscript imagemagick_test5.vbs
...
21427
21428
21429
C:\Documents and Settings\Digistar3\My Documents\arto\imagemagick_test5.vbs(9,3) (null): Catastrophic failure

arto

Re: Catastrophic failure

Posted: 2011-09-17T12:28:39-07:00
by magick
We tried your script again and this time its looped over 250,000 times and is still going. We also ran a memory checker against ImageMagick and it did not report any leaks. That leaves 3 possibilities, something about your environment, a leak in ImageMagickObject, or a flaw in your script. We did not write the ImageMagick COM object, its contributed. If the flaw is there, we must depend on a Windows developer to identify and patch. We're not sure that if you need to destroy the ImageMagick object in the your loop. It looks like we are unable to resolve this problem.

Re: Catastrophic failure

Posted: 2011-09-17T12:50:29-07:00
by oksanen
Thank you for trying! So you are not running the script under Windows? I have Win XP sp3 on the both computers. Because of camera hardware etc. I cannot choose any other operating system.

I have tried both re-using and deleting the object in the loop, neither works.

Is there any way to talk with the windows developer(s)? For me it would be not too difficult to run the script with a debugger and see what is wrong when the error happens. With the last version the error happens every time at the same moment, it is very repeatable.

arto

Re: Catastrophic failure

Posted: 2011-09-17T13:10:17-07:00
by magick
We tested your script under Windows 7, Windows XP, and Windows 2008. It ran fine on all of them for 50,000+ loops.

You are talking with the developers, we're just primarily Linux developers.

Re: Catastrophic failure

Posted: 2011-09-17T14:57:55-07:00
by oksanen
And you have ImageMagick-6.7.2-6-Q16-windows-dll.exe ? This is strange. I just ran thge script again and it failed after 21429 cycles.
Is there anything I can do to help locating the problem?

arto