Page 1 of 1

AcquireMagickMemory and multi thread

Posted: 2013-04-09T01:53:34-07:00
by vladimir_ff
Hello!
I have test app with two threads. Each thread looks like:

Code: Select all

//reading image from file to buffer
while(true)
{
   Blob blob( imageData, size );
   image.ping( blob );
}
I run this app on a 24-core system and expect loading two cores at 100%.
But it doesn't happen. Each of two cores works at 80-90%.
I explored source code and found this call sequence: Image::ping->PingBlob->CloneImageInfo->AcquireImageInfo->AcquireMagickMemory
There is a special memory manager with blocking (memory_semaphore), so I can't use full power of cores.
Am I right?
Is there any way to have memory manager for each thread?
Or may be other solution?

IM 6.7.6.9
CentOs 6.3

Re: AcquireMagickMemory and multi thread

Posted: 2013-04-10T07:06:06-07:00
by vladimir_ff
No idea? Nobody knows?

Re: AcquireMagickMemory and multi thread

Posted: 2013-04-10T08:55:49-07:00
by magick
ImageMagick uses the standard memory methods, malloc(), free(), etc. You can use any memory manager you want. Just call MagickCore::SetMagickMemoryMethods() with three methods with the same signature as malloc(), realloc(), and free().

Re: AcquireMagickMemory and multi thread

Posted: 2013-04-12T03:04:51-07:00
by vladimir_ff

"Our custom memory allocation manager implements a best-fit allocation policy using segregated free lists..."

This manager uses semaphores.
How can I make ImageMagick to use pure malloc/free without special policies and blocks?

Re: AcquireMagickMemory and multi thread

Posted: 2013-04-12T05:03:38-07:00
by magick
Our custom memory allocation manager does implement a best-fit allocation policy. However, it only used if you use this configure script option: --enable-zero-configuration. Its likely you did not use this option, therefore ImageMagick is using the standard malloc(), realloc(), and free() memory methods.