View Ticket
Not logged in
Ticket Hash: 4d87fbc7424c80f1d5c471fe7fad79077308a3b3
Title: SQLiteDataReader.GetDateTime is allocating a string in DateTimeFormat=Ticks mode.
Status: Closed Type: Feature_Request
Severity: Severe Priority: NextRelease
Subsystem: Convert Resolution: Fixed
Last Modified: 2013-07-03 10:05:22
Version Found In:
User Comments:
anonymous added on 2013-06-27 16:12:59:
The database is created/opened with DateTimeFormat=Ticks and has a column of type Timestamp. 
The DB has about 2.2 million rows.
We got the following call stack trace while memory profiling our app loading all rows:

Name	Inclusive Allocations	Exclusive Allocations	Inclusive Bytes	Exclusive Bytes	Inclusive Allocations %
System.Data.SQLite.SQLiteDataReader.GetDateTime(int32)	2.254.148	0	112.707.364	0	25,24
System.Data.SQLite.SQLite3_UTF16.GetDateTime(class System.Data.SQLite.SQLiteStatement,int32)	2.254.146	0	112.707.300	0	25,24
System.Data.SQLite.SQLite3_UTF16.GetText(class System.Data.SQLite.SQLiteStatement,int32)	2.254.146	0	112.707.300	0	25,24
System.Data.SQLite.SQLite3_UTF16.UTF16ToString(native int,int32)	2.254.146	0	112.707.300	0	25,24
System.Runtime.InteropServices.Marshal.PtrToStringUni(native int,int32)	2.254.146	2.254.146	112.707.300	112.707.300	25,24

Looking at the source code (latest version) it seems that the Ticks are loaded as type Text - creating a string for every row - which are then converted back
to an Int64 in SQLiteConvert.ToDateTime. This puts a lot of pressure on the GC. In our case about 100MB of short lived strings are allocated.
Would it be possible that in 'Ticks mode' the column data is read as Int64 which is then used to create the DateTime object without going through 
a string first?

mistachkin added on 2013-06-27 18:59:51:
I'm planning to address this issue prior to the release, which is
scheduled for sometime in the next few weeks.

mistachkin added on 2013-06-28 06:48:31:
Fixed on trunk by check-in [e1b4194a30].

anonymous added on 2013-07-03 10:05:22:
Cool. Thanks a lot.