Page 1 of 1

BMP encoder

Posted: 2015-03-02T01:33:26-07:00
by wizard29
Hello, everyone.

I found an issue of BMP encoder that looks like a bug.

When I try to save an image with 10000x10000 pixel dimension I catch an exception "Memory allocation failed" at bmp.c line 1715.
Why the BMP encoder tries to allocate so match memory at once ? How can I fix the issue?

I use Magick++, IM 6.9.0-7 for Win32.

Re: BMP encoder

Posted: 2015-03-02T03:03:43-07:00
by dlemstra
That is an implementation issue. This coder allocates the whole image instead of just a row. I will take a look if I can change this behavior.

EDIT:

You might also want to take a look at your limits. My machine can allocate the memory without any problems and could execute the following:

Code: Select all

convert logo: -scale 10000x10000! d:\logo.bmp

Re: BMP encoder

Posted: 2015-03-03T01:15:22-07:00
by wizard29
Hi.

It works fine in case of an application process only save an image. But if the application heap is partially used (about 30% for 32-bit application) for other reasons memory allocation can "randomly" fails. I guess It is not good idea to allocate so big memory block at once. May be it would be an option for the encoder.

Re: BMP encoder

Posted: 2015-03-03T03:46:21-07:00
by dlemstra
I agree with you, but that would mean a rewrite of the bmp coder. I will put this on my todo list :)

Re: BMP encoder

Posted: 2015-03-03T05:00:39-07:00
by magick
Set your area resource limit to 0. From the command-line its -limit area 0. That should force the pixels to disk rather than memory and allow your command to complete.

Re: BMP encoder

Posted: 2015-03-03T09:04:28-07:00
by wizard29
It does not help in my case.

Re: BMP encoder

Posted: 2015-03-03T14:21:47-07:00
by magick
Unfortunately we do not have access to a Win32 host. We did try Win64 and this command worked without complaint:
  • convert logo: -scale 10000x10000! logo.bmp
We even tried this on a Windows 7 virtual instance with 1GB of memory and again it completed without complaint. We're using ImageMagick 6.9.0-9, the current release.

Re: BMP encoder

Posted: 2015-03-04T00:42:35-07:00
by wizard29
Physical memory is not a restriction for the 64-bit adress space in general.