When a RadGridView's ItemSource is bound to a VirtualQueryableCollectionView, user navigation in the RadGridView causes the VirtualQueryableCollectionView to accumulate loaded objects. From a memory management perspective we would like to be able to unload objects from the VirtualQueryableCollectionView
- for example, we may want to unload anything outside the range of current row index +- 500 on an ongoing basis to limit our memory footprint.
The use case for this is any application where the user operates iteratively on a large set of large objects. When moving down the list in the RadGridView, processed rows are never viewed again yet their associated objects remain in memory unavailable to the Garbage Collector.
Unloading these objects from the collection should result in the objects being re-fetched by the ItemsLoading event handler if they are required for subsequent display in the RadGridView.
There appears to be no mechanism for identifying which items should and should not be unloaded. ResetAll does as its name implies - unloads all items - which is far too heavy handed for our desired behavior.
Setting an item to null (via RemoveAt(index), Insert(index, null) produces undesired behavior - the item is not refetched when its row is redisplayed, RadGridview displays an "=" in the row, and the item cannot be removed from the VirtualQueryableCollectionView (RemoveAt fails silently).
QUESTION: Is there a mechanism by which ranges of items can be reset in (unloaded from) a VirtualQueryableCollectionView?
I've accomplished this using reflection to remove items from the the private "loadedIndexes" collection but obviously would NOTdo that in production code.