Note that there are some explanatory texts on larger screens.

plurals
  1. POremoveFromSuperView / memory/ dynamic view switching
    primarykey
    data
    text
    <p>I have implemented a large list of views in a UIScrollView. I cannot use a table view because of the nature of my app.</p> <p>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.</p> <p>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. </p> <p>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.</p> <p>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.</p> <p>I have tried calling a memory warning on the vc</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload