Note that there are some explanatory texts on larger screens.

plurals
  1. POARC - Restructure app to prevent from crashing because of memory
    primarykey
    data
    text
    <p>I ran into problems I can't find a solution for myself so I need your help. In the following I am going to explain my app structure and then explain my problem.</p> <p>The RootViewController class manages the views that are visible on screen. In the viewDidLoad method of the RootViewController two other view controllers are being allocated. One is called DocumentViewer and is addable to the view as a modalViewController from everywhere in the app. The other one is called MapViewController and contains a view with a looping video, an image and a few buttons. Each of those buttons causes the MapViewController.view to be removed from RootViewController.view and another ViewController to be allocated in the RootViewController whos view is then added to the RootControllers view. I am gonna call those ViewControllers NewViewController for the sake of you being able to follow. This view switch is caused by a method called switchViews in the RootViewController. </p> <p>The views controlled by the NewViewControllers now each contain a segmented control inside a navigation bar. Inside the viewDidLoad method of this ViewController four other viewControllers are being allocated, three of them containing a webView and a last one with five screen sized images. All are being stored in an array called viewArray. Each time the value of the segmented control is changed a method is called that removes all views in the array that have a superview, which is always only the one currently visible, and then adds the view as a subview that is stored in the viewArray at the index of the segmentedControl element, so segment with index 0 loads [viewArray objectAtIndex:0]. A button in the navigation bar calls the switchViews method in the RootViewController to remove the current view and add the MapViewController.view again.</p> <p>So this is my application and as you may have guessed I am running into memory warning problems. For example when I am in a NewViewControllers view and call the DocumentViewer and load a pdf into it's webView I get a memory warning and the app crashes.</p> <p>Since I am using ARC for the first time and I am also not very experienced in Objective-C I don't know where to set viewController allocations to nil or stuff like that to keep memory usage on an acceptable level.</p> <p>Can anybody tell me where I need to make changes or unload content to prevent my app from crashing? Or maybe post a link to a tutorial explaining how to prevent issues like that?</p>
    singulars
    1. This table or related slice is empty.
    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