sqlite3_aggregate_context
inline fun <Data : Any> sqlite3_aggregate_context(context: sqlite3_context, noinline factory: () -> Data?): Data?(source)
Allocate or return the aggregate context for a user function. A new context is allocated on the first call. Subsequent calls return the same context that was returned on prior calls.
Ksqlite
The Data instance is created on the first call and is returned on subsequent calls. The Data instance, if created, is then made eligible for GC after xFinal() is getting called by SQLite.
If the Data instance must not be instantiated, then factory must be set to null.
If null is returned while factory is not null then the system have run out of memory.