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

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - cabbott

1
I have a fix, but you will probably want to track down the actual cause in the JPEG code and fix it properly.

LoadImageFromStream in Imaging.pas terminates prematurely if an exception occurs in Format.LoadFromStream(). It then leaves an entry in IArray with memory allocated that is never freed or allocated back to the callers Image property so the caller or FreeImage() can clear it.

Code snippet with amendments in bold:
try
    Result := Format.LoadFromStream(Stream, IArray, True);
    if Result and (Length(IArray) > 0) then
    begin
      Image := IArray[0];
      for I := 1 to Length(IArray) - 1 do
        FreeImage(IArray);
    end
    else begin
      Result := False;
    end;
except
      Result:=False;
      for I := 0 to Length(IArray) - 1 do
        FreeImage(IArray);
end;
2
Help & Questions / How thread safe is Vampyre?
8 October 2009, 15:51:35
I am seeing odd problems when running Vampyre across multiple threads.

On odd occasions it raises an exeption indicating either a Access Violation or Access Denied error reading/writing to memory. Eventually ending up with Out Of Memory errors.

Trying to debug it is a bit like the cat in the box scenario. The problem goes away if I try debugging because the threads have time to avoid memory conflicts.

Are there any areas within the following function calls that I might need to look out for or tweak?
TSingleImage.Create()
DetermineStreamFormat()
LoadFromStream()
ResizeImage()

I am only using the JPEG side of things at present

The Out Of Memory errors seem to stem from a memory leak when an exception occurs.
I'm not convinced all the allocated memory is being freed within Vampyre when an exception occurs. I am calling FreeImage() at the end of my processing regardless of the what happens during the above function calls.

If I run only one thread, or introduce delays everything is fine.
3
I am running a threaded app that is loading JPG images and then rescaling them to 32x32.

Obviously this is resulting in each image being loaded, rendered to a Bitmap at full size, then resized back to 32x32.  All of which inhales memory like it's going out of fashion because I am running 8 threads!

Is there any way of loading a JPG image and rendering it directly to a specified size, thus avoiding the huge memory overhead rendering a full size Bitmap first?

I am using other image types as well, but lets concentrate on JPG to start with!

PS. Thanks for a very comprehensive imaging library.
SMF spam blocked by CleanTalk