TSQLQuery scrolling does not free memory on memo fields
Original Reporter info from Mantis: s_tarassov
-
Reporter name: Serguei Tarassov
Original Reporter info from Mantis: s_tarassov
- Reporter name: Serguei Tarassov
Description:
TSQLQuery is set to UniDirectional for fast scrolling and extract data
The memory is not freed till the query closing when the extracted field type is ftMemo.
Steps to reproduce:
Tested on small Firebird database (attached). You should install Firebird 2.5 or try to reproduce with your DBMS creating thetest table and fill it by some data.
CREATE TABLE TEST_MEMO (
ID INTEGER NOT NULL,
NOTES BLOB SUB_TYPE 1, -- text blob type, i.e. varchar(max) in SQL Server
NAME VARCHAR(255)
);
ALTER TABLE TEST_MEMO ADD PRIMARY KEY (ID);
Compile example.
Start MemoFieldsTest.exe without parameters to scroll on blob field.
You should see memory consumption when scrolling dataset.
MemoFieldsTest.exe
Field type of NOTES is ftMemo
Field type of NAME is ftString
Row: 1000. Used heap diff: 612480
Row: 2000. Used heap diff: 1224480
Row: 3000. Used heap diff: 1836480
Row: 4000. Used heap diff: 2448480
Row: 5000. Used heap diff: 3060480
Row: 6000. Used heap diff: 3672480
Row: 7000. Used heap diff: 4284480
Row: 8000. Used heap diff: 4896480
Row: 9000. Used heap diff: 5508480
Query was closed. Used heap diff: 5936
Query was freed. Used heap diff: 752
Heap dump by heaptrc unit
78321 memory blocks allocated : 837704943/837832184
78321 memory blocks freed : 837704943/837832184
0 unfreed memory blocks : 0
True heap size : 1146880 (112 used in System startup)
True free heap : 1146768
Then restart with any parameter to scroll on varchar field.
The memory is freed correctly.
Field type of NOTES is ftMemo
Field type of NAME is ftString
Row: 1000. Used heap diff: -32
Row: 2000. Used heap diff: -32
Row: 3000. Used heap diff: -32
Row: 4000. Used heap diff: -32
Row: 5000. Used heap diff: -32
Row: 6000. Used heap diff: -32
Row: 7000. Used heap diff: -32
Row: 8000. Used heap diff: -32
Row: 9000. Used heap diff: -32
Query was closed. Used heap diff: 5520
Query was freed. Used heap diff: 336
Heap dump by heaptrc unit
49066 memory blocks allocated : 797843/955416
49066 memory blocks freed : 797843/955416
0 unfreed memory blocks : 0
True heap size : 262144 (128 used in System startup)
True free heap : 262016