I am creating a delphi application that does scientific modeling. It grows in complexity and now consists of many units and forms.
I run EOutOFMemory Errors every time I start. It seems that this happens during or immediately after I temporarily used the Array option as part of the functions. There is a risk of asking a really stupid question, are there "many options" that require trouble? (I could convert everything to a string, but an array of options basically saves a lot of fancy stuff).
using a forbid array can be:
Function TProject.GetCurrentProjParamsAsArray(LProjectName, LProjectType : ShortString): ArrayOfVariant; Var ArrayIndex : Word; begin SetLength (Result,54); ArrayIndex := 0; Result [ArrayIndex] := LProjectName; Inc(ArrayIndex); Result [ArrayIndex] := LProjectType; Inc(ArrayIndex);
In the task manager, peak memory usage is 42 MB, VM is 31M, and I get ~ 90,000 page errors for every run. (on an xp machine with 3 GB of RAM)
Does anyone have general tips on monitoring memory usage by various components of my application? or to track the cause of this error?
I recently switched from storing project master data as CSV to using ADO DB. At the same time, I also started using the Variant data type instead of always translating betweem string and single / double.
I followed various memory saving tips that I can find where practical I removed Application.CreateForm (TProject, Project); statements from .dpr And creating them dynamically. (except when forms are used in most cases in any case). In general, I use the smallest practical data type (bytes, shortstream, etc.) and minimize the use of "public" variables and functions.
any advice is very welcome, Brian
source share