problem during executing MagickWand resize method parallel (MultiThread)

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
User avatar
magick
Site Admin
Posts: 11221
Joined: 2003-05-31T11:32:55-07:00

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by magick »

Recommended practices is to call MagickWandGenesis() before you fire off any threads. Once the threads complete, call MagickWandTerminus(). ImageMagick is designed to run properly if Genesis()/Terminus() is not called, but its not recommended practice.

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

I'm Getting "Killed" as Error when I performed resize operation with 50 & above Images (Each Image size vary from 1-5MB) with MultiThread Concept in Java

Can AnyOne Help Whether the "Killed" ouput occur from the ImageMagick ?

If Its is not from ImageMagick side then I will think in other perspective

------------My Code-----------------
https://drive.google.com/open?id=1Pi4LP ... mroEfdQsy_
-----RESIZE.C-----
It is the C Program which use MagickWand API Method() to resize an image

-----MULTITHREAD.JAVA-----
It is the Java Program Which call C Program (RESIZE.C) with the help of Java Native Access
It also use MultiThread concept to parallely perform the resize operation

-------LIB Folder---------
It will have a JAR File for JNA

--------OrginalImages Folder--------
Will Have the Images Which need to resized

------ResizedImages Folder-----
Where the Resized Images will be stored

------OriginalImagesList.txt------
This File will have a list of all image which need to resized

------ResizedImagesList.txt-----
This File will have a list of names for resized Image


--------Command to Compile the C Program (RESIZE.C)-------
gcc -shared -o libresize.so -fPIC resize.c `pkg-config --cflags --libs MagickWand`
which will give (libresize.so) as output

-----------------Command to Compile the Java Program (MultiThread.java)-------------
javac -cp lib/*:. MultiThread.java
Which will give (MultiThread.class) & (MultiThread$resize.class)

--------------Command to Run the Java Program ------
java -cp lib/jna-5.5.0.jar:. MultiThread
Top

User avatar
magick
Site Admin
Posts: 11221
Joined: 2003-05-31T11:32:55-07:00

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by magick »

Killed likely means you are exceeding the memory limits of the Java program or process. Try limiting memory with a MagickCore method or with an environment variable. See MAGICK_MEMORY_LIMIT @ https://imagemagick.org/www/script/reso ... nvironment.

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

How to Limit the memory with MagickCore method ?

I set MAGICK_MEMORY_LIMIT=100MB Still Its Not Working?

Upto How Much MB I can set the Limit for MAGICK_MEMORY_LIMIT Environment variable

User avatar
fmw42
Posts: 26282
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by fmw42 »

Try changing the value in your policy.xml file. See https://imagemagick.org/script/resources.php

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

what is the Maximum size I can set for MAGICK_MEMORY_LIMIT Environment variable?

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

fmw42 wrote:
2020-03-26T21:33:31-07:00
Try changing the value in your policy.xml file. See https://imagemagick.org/script/resources.php
https://drive.google.com/open?id=19RAvi ... LnYXz9a19T

----------------policy.xml------------------

Code: Select all

<policy domain="resource" name="memory" value="2GiB"/>
What is memory here? which is same as MAGICK_MEMORY_LIMIT Environment variable?

please Explain when to use memory & MAGICK_MEMORY_LIMIT
Whether both are used for same purpose or They have different purpose

User avatar
magick
Site Admin
Posts: 11221
Joined: 2003-05-31T11:32:55-07:00

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by magick »

See the ImageMagick architecture overview @ https://imagemagick.org/script/architecture.php. To prevent excessive memory usage, limit it, and ImageMagick will push the pixel cache to disk, reducing memory requirements, with a small performance penalty.

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

https://drive.google.com/open?id=1AMOaI ... wT2thEWyol

I used MAGICK_MEMORY_LIMIT environment varaible to set the memory
I set MAGICK_MEMORY_LIMIT=1000MB in my bashrc file
when I checked with command identify -list resource the memory is updated

But When I used MAGICK_THREAD_LIMIT environment varaible to set the thread
I set MAGICK_THREAD_LIMIT=6 in my bashrc file
when I checked with command identify -list resource the thread is not updated it value is 4(thread=4) why?

snibgo
Posts: 12923
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by snibgo »

All limits add restrictions. That is, any limit you set will make the resource more limited. If anything limits you to 4 threads, then adding a limit of 6 threads will change nothing.
snibgo's IM pages: im.snibgo.com

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

snibgo wrote:
2020-03-29T05:45:50-07:00
All limits add restrictions. That is, any limit you set will make the resource more limited. If anything limits you to 4 threads, then adding a limit of 6 threads will change nothing.
I did not understand your response.I'm not asking why is not working Im asking why it is not updated the value.Since I used MAGICK_THREAD_LIMIT environment varaible to set the thread value. But the value is not changed

My question is I used MAGICK_MEMORY_LIMIT environment varaible to set the memory .I checked Whether the MAGICK_MEMORY_LIMIT is updated or not with
identify -list resource
terminal command and the memory is updated.

But When I used MAGICK_THREAD_LIMIT environment varaible to set the thread .I checked Whether the MAGICK_THREAD_LIMIT is updated or not with
identify -list resource
terminal command and the thread value is not updated why?

snibgo
Posts: 12923
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by snibgo »

Something limits your threads to 4. You can reduce this with MAGICK_THREAD_LIMIT=3 or MAGICK_THREAD_LIMIT=2. But you can't increase it, relax the limitation, with MAGICK_THREAD_LIMIT=6 or any number larger than 4.
snibgo's IM pages: im.snibgo.com

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »

Yes your correct I was able to decrease the thread limit & not able to increase the limit
But why such limit ..
Are there any reason that Im not able to increase the thread?

snibgo
Posts: 12923
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by snibgo »

How many cores does your CPU have?
snibgo's IM pages: im.snibgo.com

ArunKumar
Posts: 38
Joined: 2020-03-05T00:12:15-07:00
Authentication code: 1152

Re: problem during executing MagickWand resize method parallel (MultiThread)

Post by ArunKumar »


Post Reply