Closed Grunthos closed 12 years ago
Simply copying the entire cursor contents to a MatrixCursor and using that results in:
(a) Almost identical run time (b) 33% reduction in total memory used by loading a completely expanded list and (c) A reduction in active SQLite cursors from 337 to 1.
This seems like a win to me!
Fixed in V4.0
Experimenting with large collections of books has revealed a limit in SQLite that we are likely to experience.
For each group in an ExpandableListView that is expanded, we return a cursor.
If someone clicks 'Expand All', we return 1 cursor for each group.
If that person has somewhere in excess of 800 (not sure exact number) of groups, SQLite will run out of memory/file descriptors/something.
It seems that ExpandableListView keeps thos cursors open for the entire time.
Couple this with the 'fact' (garnered from google) that the memory requirements of an SQLite cursor are not small, and we probably have a problem in the future, or anyone with a large collection now.
[As an aside, we also have a bug where these cursors are not being closed when the BookCatalogue activity is 'stopped'...only when it is destroyed, resulting in excess cursors being kept in memory until a GC]
As someone with about 337 authors, I always scream when I accidentally click 'Expand All' (I can go make a cup of coffee while I wait for it to complete), I have an interest in this area as well.
I am not entirely sure what the best solution is. Some suggestions come to mind:
I'd be very interested in any other ideas!