Mike Chaney's Tech Corner

Mike's Software => Qimage Ultimate => Topic started by: ZprinterInOslo on February 10, 2013, 09:48:33 PM



Title: Memory issues and a suggestion
Post by: ZprinterInOslo on February 10, 2013, 09:48:33 PM
Hello, I have been using v2012.221 so far, but plan to upgrade to 2013.110 when I'm done with this printout.
Was trying to load and print some PNG images that measure 16384x16384 with color type : 6 (RGB + alpha)

The thumbnails show up as "Image Read Error". Removing the alpha channel brings the uncompressed imagedata below 2GB and I'm able to load them

I would like to suggest a couple of improvements.
  • If the thumbnailer runs out of memory please say Out of memory or something to that effect instead of a more generic error which also suggest a bad image file
  • In lieu of a 64-bit version can you build a 32-bit release which supports LARGEADDRESSAWARE

(The memory dialog under Help->Analyze shows Start: 2000MB, Addl: 1774MB, Now: 2000 MB)

If you build a release that is LARGE ADDRESS AWARE 32-bit users can get 3GB and 64-bit users get 4GB of memory. http://msdn.microsoft.com/en-us/library/aa366778.aspx#memory_limits (http://msdn.microsoft.com/en-us/library/aa366778.aspx#memory_limits)

Delphi seems to use {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} in the project settings (http://stackoverflow.com/questions/2740308/why-2-gb-memory-limit-when-running-in-64-bit-windows (http://stackoverflow.com/questions/2740308/why-2-gb-memory-limit-when-running-in-64-bit-windows))
and MS VC needs Enable Large Addresses set: http://msdn.microsoft.com/en-us/library/wz223b1z.aspx (http://msdn.microsoft.com/en-us/library/wz223b1z.aspx)

Thanks for listening, and I have been quite satisfied with Qimage so far.


Title: Re: Memory issues and a suggestion
Post by: admin on February 11, 2013, 12:03:47 AM
Thanks for the suggestions!  Qimage Ultimate has actually been compiled with the largeaddressaware flag for years.  If it wasn't, you wouldn't see 2GB in the analyze settings.  The only reason the analyze settings shows 2GB is because it doesn't test anything larger than that: I'll change that in the next version.  When it is changed to read the actual maximum memory, mine shows 2147 MB with additional 1250 MB (on 64 bit Windows).  The problem here is the way Windows manages memory.  When dealing with bitmaps, it needs contiguous memory.  So if you are working with a 1 GB image and you have 3 GB available but the largest contiguous block available is 800 MB, Windows will throw an out of memory error due to the memory fragmentation.  In addition, if you want to load a 1 GB image, you'll need 2 GB of memory to do it reliably because some operations (like filters and even rotations) require an extra copy in memory.

I'll take a look at the thumbnail building but that already has some sophisticated memory management because 4 threads are running at the same time.  You can imagine how difficult it is to manage memory when it is trying to build four 1 GB images at the same time: threads have to be told to wait until memory is available, etc.  But I'll see if I can improve on that.

Regards,
Mike