Search code examples
delphiout-of-memorydelphi-10-seattledevart

How to find the source of a big memory consumption in a Delphi application?


I am experiencing a non normal memory consumption from my application written in Delphi 10 Seattle. It is a client server fat client type of application using SDAC's Devart as DB component.

I am not aware of specific tools, but I would like to know what causes the memory consumption.

What I observe is the following: as i launch a command the memory used by the exe grows a lot (up to 1 GB, in an app that used to use up to 200MB max) and sometimes this ends in an out of memory error. The stack trace of the out of memory error is of no use and seems random.

Could anyone please suggest a technique to study memory consumption?

I am currently studying memory leaks with FastMM4 and I managed to remove some, but there are just minor ones (TStringlist or some small TBitmap), nothing that justifies 1GB of memory consumption.

Is there a way to say "unit4.pas allocated 100MB of RAM" or any other similarly useful memory usage report?

Thanks a lot.

I feel stuck since I do not know the tools for this task.


Solution

  • Do you query database table columns with a BLOB type? If yes then figure out the largest datasets and see if avoiding them avoids memory consumption. With PHP 7.1 I had a similar problem with MySQLi on TEXT columns (older bug and Longtext max memory error using mysqli_query).

    Actually solving/preventing the memory consumption can surely be done - the database abstraction layer surely knows an alternative method to query such columns in a way that works better for both sides: server and client. Feel free to edit this answer to include your actual code.