SDAC and memory usage

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

SDAC and memory usage

Post by yeohray » Tue 26 Feb 2008 07:53

I have a SQL Compact database that's around 136 MB in size. I run a query that returns around 190,000 rows using TMSQuery connected to a TMSCompactConnection. Using the Windows Task Manager, I see that my app consumes around 1.2 GB of virtual memory. In some cases, SDAC returns an 'Out of memory' error.

Is this normal? How can I reduce the memory consumption?

Thanks.

yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

Post by yeohray » Wed 27 Feb 2008 10:22

Since I didn't need an updateable dataset, I set unidirectional to true, and copied the entire dataset to a VirtualTable. This reduced the memory consumption greatly.

However, the VirtualTable.AssignDataSet method is extremely slow, because of the following code:

Code: Select all

SourceField := Source.FieldByName(Fields[i].FieldName);
The FieldByName method is the bottleneck. Maintaining an array that maps each source column to a target columns results in much better performance. The Assign method took 35 seconds in my app previously. Adding an array to map the columns reduced the time to 5 seconds.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Wed 27 Feb 2008 12:59

Thank you for your assistance. We will add this optimization in the next build of SDAC.

Post Reply