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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 access violation in 64bit applications
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jokli

2 Posts

Posted - Aug 14 2013 :  03:17:37  Show Profile  Reply
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)

fab

1310 Posts

Posted - Sep 06 2013 :  00:24:47  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: