Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Losing system memory

edited July 2002 in General
RB6, Delphi 6, Win2K, InterBase, IBObjects

When I run reports with MyApp.exe, the "memory usage" (Windows Task Manager) increases, and does not decrease when the printing or previewing finishes. I use a single report component to load and
print report templates. The application ends up using so much memory (100MB+) after a few active hours that you must restart the program.

Here is some "memory usage history" for a report that is about 10-12 pages long (slightly rounded numbers). About 4 MB of memory is lost, each time I run the report:

Call #1 to "Run Report X:
AutoSearchParams input form appears: 11700
Preview form appears 20500
Preview form closes 20450

Call #2 to "Run Report X" 20450
AutoSearchParams input form appears: 19700
Preview form appears 24500
Preview form closes 24500

Call #3 to "Run Report X" 24500
AutoSearchParams input form appears: 23000
Preview form appears 26400
Preview form closes 26400

Call #4 to "Run Report X" 26400
AutoSearchParams input form appears: 26400
Preview form appears 30100
Preview form closes 30100

Call #5 to "Run Report X" 30100
AutoSearchParams input form appears: 30200
Preview form appears 33900
Preview form closes 33900



Here is the Delphi code that calls/runs the report, selecting the DataBaseSettings.Name from a list of objects of type T5402, which have a field called "strB", which contains the report name:

rpReports.Reset;
tblReports.Active := false;
rpReports.Template.DataBaseSettings.Name := T5402(ReportList.Items.Objects[dx]).strB;
tblReports.Active := true;
//RUN:
rpReports.Template.LoadFromDatabase;
rpReports.Print;

Is there something I should be doing to release that memory? This is obviously a BIG problem, since a user only has to run a report like this one 30 times to use up 128 MB of memory, and long before
that the machine is running too slow to tolerate.

Dennis McFall

Comments

  • edited July 2002
    There is a number of reasons that memory usage is up after the report has
    ran and ways to minimize memory usage.

    1. The tables cache the incoming data. Close the tables to free their cache.
    2. CachePages on the report is true and the generated pages are cached in
    the publisher. Set CachePages to false or clear the PageCache after you're
    done viewing the report.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited July 2002
    > 1. The tables cache the incoming data. Close the tables to free their
    cache.
    Some datasets can be 'unidirectional'. Will this help? Or rather, can RB
    operates properly with Unidirectional datasets ?

    Thanks In Advance,
    salam,
    sugi.
  • edited July 2002
    On Wed, 17 Jul 2002 09:16:49 -0500, "Alexander Kramnik \(Digital Metaphors\)" wrote:

    CachePages is false. I added "tblReports.Close", but the memory usage did not change. What are "The tables"? This is an end-user report, so how can I close or otherwise affect "the table", since there
    are no pipeline, dataSource, or table/query components (although of course there is some kind of dynamic creation of data components going on behind the Report Builder scenes, to get the data ).

    This is the code I just used, and the total memory usage for the application increased by 3.7MB, then 3.9MB more, then 3.7MB more, as I ran the same report three times.

    rpTestA.Reset;
    tblTestA.Active := false;
    rpTestA.Template.DataBaseSettings.Name := T5402(TListBox(Sender).Items.Objects[dx]).strB;//'TEST3';
    tblTestA.Active := true;
    rpTestA.Template.LoadFromDatabase;
    rpTestA.Print;
    tblTestA.Close;
  • edited July 2002
    RB requires that the datasets be bidirectional.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited July 2002
    Even in an end user report, behind the scenes, pipelines and tables are
    created and data is cached. You can manually go through the data view's and
    close their pipelines. Do you have any code executing with the report? If
    so, are you cleaning that up properly? In short, RB does not provide any
    kind of a memory usage guarantee. If you have reason to be concerned with it
    try using something like Sleuth QA to look for memory leaks in your
    application.

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.