Problem
In database query results, many columns exhibit low cardinality (e.g. status codes like 'active', 'pending', booleans, enum values, country codes, category names).
Currently, convertResultRowsToStringsAdaptive in lib/core/database/result_row_string_convert.dart converts every cell into a standalone String instance. In a 50,000-row result set with repeated values, this creates tens of thousands of duplicate string objects in the Dart VM heap, consuming unnecessary memory.
Proposed Solution
- Implement a lightweight, thread-safe string interning pool (e.g.
StringPool / LRU deduplication map) during result row decoding in result_row_string_convert.dart.
- Deduplicate frequently repeated string instances so identical values share the same
String pointer in memory.
- Add unit and memory benchmark tests demonstrating up to 40–60% heap reduction on low-cardinality test datasets.
Problem
In database query results, many columns exhibit low cardinality (e.g. status codes like
'active','pending', booleans, enum values, country codes, category names).Currently,
convertResultRowsToStringsAdaptiveinlib/core/database/result_row_string_convert.dartconverts every cell into a standaloneStringinstance. In a 50,000-row result set with repeated values, this creates tens of thousands of duplicate string objects in the Dart VM heap, consuming unnecessary memory.Proposed Solution
StringPool/ LRU deduplication map) during result row decoding inresult_row_string_convert.dart.Stringpointer in memory.