TfrxPDFExport cause GDI Handles leak when runing in thread

edited 6:20PM in FastReport 4.0
Hi,

I have problem with memory leaks in TfrxPDFExport. My application create some reports and export it to pdf in one separated thread. I prepare simple application to demonstrate problem.

When I run this code in main thread everything is ok.

frxReport1->PreviewPages->LoadFromFile("Test.fp3");
frxPDFExport1->FileName = "Test.pdf";

for(int i=0; i<1000; ++i)
{
frxReport1->PreviewPages->Export(frxPDFExport1);
}

When I run above code in thread the private bytes and GDI Handles starts to grow.
Especially when I start to manually move or resize application windows.
It's probably because pdf export not properly uses canvas.

Any help appreciated.
Best regards,
macma



Comments

  • edited July 2013
    Macma wrote: »
    Hi,

    I have problem with memory leaks in TfrxPDFExport. My application create some reports and export it to pdf in one separated thread. I prepare simple application to demonstrate problem.

    When I run this code in main thread everything is ok.

    frxReport1->PreviewPages->LoadFromFile("Test.fp3");
    frxPDFExport1->FileName = "Test.pdf";

    for(int i=0; i<1000; ++i)
    {
    frxReport1->PreviewPages->Export(frxPDFExport1);
    }

    When I run above code in thread the private bytes and GDI Handles starts to grow.
    Especially when I start to manually move or resize application windows.
    It's probably because pdf export not properly uses canvas.

    Any help appreciated.
    Best regards,
    macma

    Ok I found reason of the problem:

    It's in frxExportPDF.pas line 2737:

    TempBitmap.Width := Round(dx * i) + i;
    TempBitmap.Height := Round(dy * i) + i;

    Obj.Draw(TempBitmap.Canvas, i, i, -Round((Obj.AbsLeft - fdx) * i) + iz, -Round((Obj.AbsTop - fdy)* i));

    Should be:

    TempBitmap.Canvas.Lock;
    try
    Obj.Draw(TempBitmap.Canvas, i, i, -Round((Obj.AbsLeft - fdx) * i) + iz, -Round((Obj.AbsTop - fdy)* i));
    finally
    TempBitmap.Canvas.Unlock;
    end;

    Is there someone from FastRepost Team that could confirm and fix this error in current version?
    PS.

    At first glance I see that there is more GDI issues in other exports too.

    Best regards,
    macma
  • edited 6:20PM
    Sorry for response delay. Your patch was accepted and sent to repository. Next build will include your patch.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.