[Delphi] LoadFromIStream

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
BennyCUAG
Posts: 6
Joined: Wed Mar 07, 2012 6:45 pm

[Delphi] LoadFromIStream

Post by BennyCUAG » Fri Mar 13, 2015 4:38 pm

Hello. We are using GDPicture with Delphi. It seems that using LoadFromIStream causes a memoryleak (fastmm ).
Here is a sample code:

Code: Select all

  ms := TMemoryStream.Create();
  ms.LoadFromFile('C:\temp\test.pdf');
  DociStream := TStreamAdapter.Create(ms,soOwned);

  GdPicturePDF1 := CreateComObject(CLASS_GdPicturePDF) as _GdPicturePDF;
  if GdPicturePDF1.LoadFromIStream(DocIStream) = 0 then begin
          GDPicturePDF1.CloseDocument;
  end;

  GdPicturePDF1 := nil;

  DociStream := nil; // nothing happened here
Memory Leaks:
TMemoryStream + TStreamAdapter

TMemoryStream should be released with TStreamAdapter but it seems TStreamAdapter isnt released. Any ideas why?

Edit - this works fine:

Code: Select all

  ms := TMemoryStream.Create();
  ms.LoadFromFile('C:\temp\test.pdf');
  DociStream := TStreamAdapter.Create(ms,soOwned);
  // no gdpicture here
  DociStream := nil; 

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: [Delphi] LoadFromIStream

Post by Loïc » Sat May 16, 2015 4:04 pm

Hello,
TMemoryStream should be released with TStreamAdapter but it seems TStreamAdapter isnt released. Any ideas why?
To make it simple: GdPicture will never close the provided stream, this is not his task.

Just let me know if you need some elaboration.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest