I have implemented a large list of views in a UIScrollView. I cannot use a table view because of the nature of my app.
Basically I have a collection of 'blocks' which are view controllers themselves, inside a UIScrollView. Everything is working OK but memory is a problem on very large pages. I have successfully implemented dynamic adding of the subviews (when they come on screen, they are layed out and added to the parent view). The blocks themselves are setup and created all at once but their actual views, ie, block.view, are not added to the big container until they come on screen. This works great, but I need a way of removing the views from memory once they go offscreen. removeFromSuperView does make them disappear however doesn't reduce the memory usage.
If I instantly removeFromSuperView, after addSubview, the block isn't displayed and the memory doesn't go up. If I removeFromSuperview after a draw cycle, the memory goes up on the draw and doesn't go back down, even though you cannot see the view anymore. It's like the view is being cached until I actually release the entire view. This doesn't make sense because it wasn't using much memory before drawing it, even though it had been created.
I cannot release the view since it belongs to my block (viewcontroller) which holds a lot of other (eg, layout) information. I just need to get the memory back. I know that keeping the view in memory before a draw cycle isn't causing the memory to go up therefore I shouldn't need to get rid of it.
For example, if I retain instead of addSubview, I know that my view is still around, but it doesn't use nearly as much memory.
I have tried calling a memory warning on the vc