Page 1 of 1

Out of Memory Problem

Posted: Fri 20 Oct 2006 03:53
by Veli
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]

Posted: Sat 21 Oct 2006 20:37
by teunis
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

Posted: Mon 23 Oct 2006 11:28
by Antaeus
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.