ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 access violation in 64bit applications

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jokli Posted - Aug 14 2013 : 03:17:37
First I want to say that the more longer I work with ImageEn, the more I like it.

But actually I experienced some strange behaviour:

I develop a server application, which handles large amounts of image data. Some requests want to retrieve images after being manipulated (e.g. resized), so in order to enhance the performance, I work with parallel threads, according to the number of CPUs.

The threads are created in a loop, almost at the same time:

for i := 0 to aResultList.Count-1 do
  thr := TImageManipulationThread.Create(aResultList[i],aParamList,aSessionInfo,DoAllImageManipulations,
                                            FLogger, OnImageManipulationThreadTerminated, false);


In each thread, following code is performed:

  ieIo := TImageEnIO.Create(nil);
  ieio.AttachedIEBitmap := ieBmp;
  ieio.Params.JPEG_DCTMethod := ioJPEG_IFAST;
  ieio.Params.Width := iWidth;
  ieio.Params.Height := iHeight;
  ieio.Params.JPEG_Scale := ioJPEG_AUTOCALC;
  ieio.LoadFromStreamJpeg(aJpegStream);

When I compile this as a 32bit application (Delphi XE2), everything works fine. When I compile this as a 64bit application, the last line produces an access violation (ievision64.dll), when it is simultaneously run in more than one thread. When I create only one thread first, then everything goes fone, even when I create multiple threads after that.

I found a workaround for 64bit applications. When I run the following code at application startup, everything works fine:


    jp := TJPEGImage.Create;
    try
      ms := TMemoryStream.Create;
      try
        jp.Assign(Image1.Picture.Bitmap);
        jp.SaveToStream(ms);
        ms.Position := 0;
        ieBmp := TIEBitmap.Create;
        try
          ieio := TImageEnIO.Create(nil);
          try
            ieio.AttachedIEBitmap := ieBmp;
            ieio.Params.Width := 300;
            ieio.Params.Height := 400;
            ieio.Params.JPEG_Scale := ioJPEG_AUTOCALC;
            ieio.LoadFromStreamJpeg(ms);
          finally
            ieio.Free;
          end;
        finally
          ieBmp.Free;
        end;
      finally
        ms.Free;
      end;
    finally
      jp.Free;
    end;


Nevertheless, this is not a really satisfying solution. I suppose that some code in an "initialization routine" of ievision64.dll is not thread safe, and that once it is initialized, everything goes fine.

Can you have a look at this?

Kind Regards
Joachim Klingenfuss
(jokli4711@gmx.de)
1   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Sep 06 2013 : 00:24:47
Hello,
this is a known problem (thread safe problem loading using external dll) and has been fixed on currently developing version.
You can get a beta version which should fix this bug. Please look at:

http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1204