Out of Memory Problem

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Veli
Posts: 4
Joined: Thu 19 Oct 2006 05:51

Out of Memory Problem

Post by Veli » Fri 20 Oct 2006 03:53

Hi,
I have a large table("test") in my MySql type database.Table size is around 450Mbyte.I am using Borland C++ Builder 5.My compilier is giving "out of memory" exception while executing
"Table_Test->Active=true;" statement.

Apperantly component (TMyTable) is trying to put whole table into memory.

Could you please give me some idea to overcome this problem except shrinking table size?.I am interested with solutions which can modify component properties which can avoid taking whole table into memory but taking piece by piece.

Thank you.

Code: Select all

TMyTable *Table_Test;
Table_Test = (TTable*)(new TMyTable(this));
// ------ connect tables to CDR Database -------
((TMyTable*)Table_Test)->Connection = ptMySqlDatabase;
((TMyTable*)Table_Test)->TableName = "test";

Table_Test->Active = true;

if(Table_Test->RecordCount)
{
  Table_Test_exist=true;
}
[/code][/list]

teunis
Posts: 48
Joined: Wed 01 Feb 2006 14:15
Location: Curacao

Post by teunis » Sat 21 Oct 2006 20:37

You should not use TMyTable for huge tables
The statement MyTable1.Active:= TRUE is the same as executing the SQL:
SELECT * FROM table
MySQL will send all records to the machine where the program is executing and
of course that can cause a memory problem.
It is better to use a Querry and let MySQl send you the relevant records
Teunis

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 23 Oct 2006 11:28

teunis's suggestion is correct.
One more way to decrease memory usage is to enable Unidirectional mode. In this mode records are fetched to the client on demand (like in FetchAll=False mode). But the records are not cached on the client, so you can browse the record set forward only. Unidirectional mode can be useful for example for printing huge reports.

Post Reply