• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

high memory consumption

Started by bungarus, 19 October 2008, 18:33:09

Previous topic - Next topic

bungarus

Hi,

loading some types of jpeg image in function alloc_barray the
calculation of max # of rows allowed in one allocation chunk gets 0.
This causes call of ERREXIT in line 496, which should stop operation
but original ImagingJpeg.pas has empty JpegError procedure body so
operation doesn't stop.
Host sucks on high memory allocation.
Of course you get an out of memory message later, but you can't load any image longer.


See attached image.

regards

Galfar

Could you please attach here some of the jpegs that cause this error?
I know there are some problems with progressive jpegs.

bungarus

Ok, I got your tips.

Imagelib 0.26.0
Compiler FPC 2.2.0
OS MS Vista Home SP1

Attached an image causing error. Saved with Adobe Photoshop Elements 5.0.

Anyway, nice lib. Thanks.

Galfar

Found the problem!

In alloc_barray there is:

ltemp := (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) div
  (long(blocksperrow) * SIZEOF(JBLOCK));
if (ltemp <= 0) then
  ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);

ERREXIT calls JpegError in ImagingJpeg.pas which should stop further loading.
Since JpegError is empty it continues to mem allocation code.
But it only happens in FPC in Windows, not FPC Linux or Delphi.
Then I noticed this in jmemnobs.pas unit:

{$IFDEF WINDOWS}
const
  MAX_ALLOC_CHUNK = long(32752);
{$ELSE}
const
  MAX_ALLOC_CHUNK = long(1000000000);
{$ENDIF}

WINDOWS symbol is defined in FPC Win32 and MAX_ALLOC_CHUNK is too small
so ltemp is zero and error gets raised.

Fix is easy but problem is here: ImagingJpeg uses PasJpeg in FPC instead of
my modified JpegLib version present in Imaging. So it will have to be disabled -
Imaging compiled using FPC in Windows will use Imaging's JpegLib.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk