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

Time:02-24

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.

CodePudding user response:

What you need is a good memory/allocation profiler.

I don't know what features are typical or not in such a profiler because I only ever used one, but the one I use allows to get a report at anytime during a run that shows all the allocated memory and where in the application said memory was allocated.

CodePudding user response:

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.

  • Related