Out of memory when I activate one of my MemDataTable

Hi,
I’m using Delphi XE and RO/DA to access an SQLite DB through the AnyDac driver. I’m using a DA DLL server.

Problem: I have one table which is pretty big and when I activate the client’s DAMemTable, I get an out of memory exception from the server. Why is that ? How can I avoid that ? Is the whole table loaded on the client ?

I’m sure I’m doing something stupid here but any help would be greatly appreciated.

can you send your project or create a simple testcase that reproduces this behavior to support@, pls?
by other hand, you can start server in debug mode and see place where exception is happened - in DA or in AnyDAC.

I can’t pinpoint the exact exception location, don’t know why. I’ll try to create a sample application showing the problem. Meanwhile, please answer that simple question: will the client’s TDAMemDataTable always have ALL the data contained in the DB opened by the server or is there a way to do better ?

As far as I can see, currently, the DLL server loads hundreds of MB of data per client request, then seems to hold that in memory while send it to the client, which in turn holds all of that data in memory too, then the server frees its memory. Is that correct ? If yes then it means that for a 2GB DB, I’ll need at least 4GB of free RAM ? This seems odd.

TDAMemDataTable loads all records that are returned by your sql request.
if you don’t need all data, you can use loading by demand, as it is shown in the Fetch sample or limit it with DynamicWhere.
by other hand, you can skip loading of “heavy” blobs at opening of table and load them in separate request.

you are right - data stream is stored on server-side while it is sending to client.

I got the same problem with some big tables at designtime.
When I set the memtable on active I get this error for big tables. I got my server on an other machine

Delphi IDE could limit amount of memory that is accessible for components.

Ok so I’ve developped a work around implying an RO function called by the client sending a Binary to the server. Now I’m dtuck as I don’t know how to save that binary in a Blob field on the server. Could you please give me a sample on how to do that ?

Binary is descendant of TMemoryStream so you can use it as usual TStream.
You can use this code:

.LoadFromStream(NewROStream(,False));