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
 TImageEnMView and Memory
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flashcqxg

12 Posts

Posted - Jan 13 2021 :  03:08:48  Show Profile  Reply
My code is as follows:
for I := 0 to ImageEnMView.ImageCount - 1 do
  begin
    try
      ImageEnMView.GetBitmap(I);
    finally
      ImageEnMView.ReleaseBitmap(I, False);
    end;
  end;

There are 120 pictures in ImageEnMView, each picture is about 80kb.When this program is executed for the first time, the program occupies about 30M of memory. After the second time, each execution occupies a maximum of about 1.2G of memory. Is this normal?
Thanks.

xequte

5759 Posts

Posted - Jan 13 2021 :  19:15:38  Show Profile  Reply
Hi

GetBitmap converts the internal storage of images to TBitmap, which has poor memory handling.

You are better to use TImageEnMView1.GetTIEBitmap. If you need a TBitmap use TIEBitmap.CopyToTBitmap to copy the result to your bitmap.

const
  USE_GETBITMAP = False;
var
  I: Integer;
  bmp: TBitmap;
  iebmp: TIEBitmap;
begin
  for I := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    bmp := nil;
    try
      Caption := IntToStr( i ) + ' - ' + ImageEnMView1.ImageFilename[i];

      if USE_GETBITMAP then
        bmp := ImageEnMView1.GetBitmap(I)
      else
      begin
        bmp := TBitmap.Create;
        iebmp := ImageEnMView1.GetTIEBitmap(I);
        iebmp.CopyToTBitmap( bmp );
      end;

      // do somethign with bmp...
    finally
      if not USE_GETBITMAP then
        FreeAndNil( bmp );
      ImageEnMView1.ReleaseBitmap(I, False);
    end;
  end;
  MessageBeep(0);
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Flashcqxg

12 Posts

Posted - Jan 14 2021 :  03:30:24  Show Profile  Reply
Hello xequte,i have test the code,but same.
After the second time, each execution occupies a maximum of about 1.2G of memory.
Go to Top of Page

xequte

5759 Posts

Posted - Jan 14 2021 :  20:57:44  Show Profile  Reply
Hi

The process above will load all images (if they were not previously loaded) into the TImageEnMView. Storage will be based on StoreType:

https://www.imageen.com/help/TImageEnMView.StoreType.html

So if StoreType is ietNormal, for instance, and images were loaded on demand (so not all initially loaded) then your code above will force the loading of all the images into memory. After the process completes they would remain in memory.

That doesn't explain why it wouldn't happen the first time though, so I suspect something else is going on. Can you email me a small demo project that shows the issue.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Flashcqxg

12 Posts

Posted - Jan 14 2021 :  21:30:30  Show Profile  Reply
Hi
I have emailed the demo.
Go to Top of Page

xequte

5759 Posts

Posted - Jan 14 2021 :  21:56:40  Show Profile  Reply
Thanks, I can reproduce the issue and we are investigating.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: