How to disable memory limits in Magick++

495 Views Asked by At

How to disable any memory limits in Magick++? I don't want to have any limits, I'd prefer std::bad_alloc on memory exceeds.

I tried.

Magick::InitializeMagick( nullptr );
Magick::ResourceLimits::memory( 0 );
Magick::ResourceLimits::map( 0 );

But Magick++ ignores it.

These static methods receives unsigned values, and I tried big enough values, like 9999999999, but Magick++, as said, ignores them.

1

There are 1 best solutions below

5
On

I don't believe you would be able to disable the resource limits as it's fundamental to the MagickCore library.

I tried big enough values, like 9999999999, but Magick++, as said, ignores them.

During the genesis routines, the systems maximum limits are identified, then further reduced based on security policies (policy.xml), and environmental variables. Attempting to set memory at any value greater then what is identified during geniuses would be ignored. Ideally Magick++'s Magick::ResourceLimits::.... setters should return a boolean on success; thus, matching MagickCore's behavior.

I don't want to have any limits, I'd prefer std::bad_alloc on memory exceeds.

Although I agree with you that it would be nice to rely on C++ standards, I doubt std::bad_alloc would be issued correctly. The core library does a good job balancing large streams/buffers of data between temporary, cache, and memory resources. If, somehow, you could disable limits in the core library, then this balance would be thrown off, and I would suspect that this would cause way more false-negative exceptions.