Skip to content

Memory usage. #13

@sdrpa

Description

@sdrpa

First of all, thank you for the great component, I have small tip about improving memory usage for the infinite grid.

I noticed huge memory usage while profiling an app. using the infinite grid view.
When you scroll the infinite grid, method

tileGridsFromMinX:toMaxX:

which adds/removes views from one side using either

 [lastGrid removeFromSuperview] or [firstGrid removeFromSuperview] 

in ARC env. [lastGrid removeFromSuperview] doesn't release the view.

Similar problem I encountered with CorePlot: https://groups.google.com/forum/#!searchin/coreplot-discuss/memory/coreplot-discuss/nWui9VjnMtQ/er2FO3o9syYJ

If you do:

lastGrid = [self.visibleGrids lastObject];
while (lastGrid.frame.origin.x > maximumVisibleX) {
   [lastGrid removeFromSuperview];
   [self.visibleGrids removeLastObject];
   [self.gridReusableQueue addObject:lastGrid];

   lastGrid = nil;

   lastGrid = [self.visibleGrids lastObject];
}

Memory usage is much more efficient. I've tested it in instruments, without lastGrid = nil I can easily reach 60Mb after 30 seconds of scrolling, with the line it increases but very slowly stays around 15Mb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions