Description

Looking at Android Device Monitor, memory usage appears to balloon on Android when using .setSections() on a ListView, particularly when the ListDataItem array for the ListSections is large and when sections are set multiple times. Memory doesn’t seem to clear even when the ListView is removed and its parent controller proxy is cleared and the controller is destroyed. The attached project demonstrates the issue. Clicking "Open List View" populates the ListView with 5 ListSections, each with 1,000 ListDataItems. Clicking "Repopulate List View" creates a new set of 5 sections and sets those sections on the existing list view. The memory footprint increases significantly with each repopulation and never seems to reset. Clicking "Close List View" destroys the controller holding the ListView, but the memory doesn’t appear to reset in that scenario either. Eventually the application runs out of memory and crashes.

Additional notes: If I put a single ListSection in the XML for the ListView and use setItems on that single ListSection the memory does appear to reset, so it seems to be related to setSections, however in both scenarios if I close the view and destroy the controller the memory does not reset.