Vampyre Imaging Library Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Imaging 0.26.4 Released!

Author Topic: high memory consumption  (Read 1559 times)

bungarus

  • Imaging User
  • *
  • Offline Offline
  • Posts: 2
    • View Profile
high memory consumption
« on: 19 October 2008, 18:33:09 »

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
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: high memory consumption
« Reply #1 on: 22 October 2008, 23:56:33 »

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

bungarus

  • Imaging User
  • *
  • Offline Offline
  • Posts: 2
    • View Profile
Re: high memory consumption
« Reply #2 on: 25 October 2008, 14:36:54 »

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.
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: high memory consumption
« Reply #3 on: 31 October 2008, 13:15:36 »

Found the problem!

In alloc_barray there is:
Code: [Select]
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:
Code: [Select]
{$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.
Logged
 

Page created in 0.06 seconds with 19 queries.