I'm having issues of Low memory Memory. Every time memory grows when push the view. I am using Xcode 6.1 - ios7

I'm having issues of Low memory Memory. Every time memory grows when push the view. When i run the Instruments i saw it is ImageIO_PNG_Data, which takes the grows lots of memory every time i push the view. My old application is working fine, but when i change some images it gives me low memory problem.
Image URL: https://drive.google.com/file/d/0B5FeQzPDrl-oT2ZiZktuNWJONHM/view?usp=sharing
Guys please have a look.
Thanks guys.

I'm going to guess, on no evidence (since you have given no information at all), that you have set up a circle of push segues in your storyboard: you push view controller A, then push view controller B, then push view controller A, then push view controller B, and so on. Thus, you wind up with dozens of view controller A and view controller B all pushed on top of each other. And since every view controller A contains the image, you wind up with dozens of images. And so you eventually run out of memory.
If that is true, you need to understand that the opposite of a push segue is not a reverse push segue - it is a pop, or an unwind segue. Similarly for present (modal); the opposite is not another present (modal), it is a dismiss, or an unwind segue.

Related

MemoryManagement with UINavigationController

I have an "issue" with my NavigationController. Actually it seems to me, that this behavior seems to be intended.
My App uses a SplitViewController, using a TableViewController for the MasterView and a NavigationController for the DetailView.
I have 4 views, which i can switch from each to another. What I observed is that every time I use one of the NavigationController buttons to change the View the memory consumption increases by almost 1.5MB.
Using the back-button of the NavigationController the views seem to get released correctly as the used memory decreases.
I read that the views are put on a stack every time i switch them, but actually that is not what I need (At least I hope so, because at a certain degree I rely on the viewdidload-method to update the content, which I pass via NSNotification to each view. At that point it would be nice if all views could share that passed userInfo, but that's a different story...).
So what I'm looking for is a way to replace the newest ViewController on the NavigationController view stack by the one. I don't need a history of like 100 views where like 40 views always are actually the same. I only found answers about memory not getting released after using the back button. Therefore I assume the current behavior is the intended one.
what I'm looking for is a way to replace the newest ViewController on the NavigationController view stack by the one
setViewControllers:animated: lets you construct the stack however you like.
https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html#//apple_ref/occ/instm/UINavigationController/setViewControllers:animated:

Completely unload a ViewController at modalTransition?

normally after a modal transition, the second viewController runs further "behind" the visible ViewController in the background.
Is there a possibility to completely unload the second ViewController ??
If don't want to use push, because I want an animation on the transition...
Several points:
You are worrying about something that is not a worry. View controllers are lightweight, simple objects. The only heavyweight object is the view, and it is in fact removed from the interface when another view controller's view is presented in its place.
The game does not "run in the background". If it does, you're doing it wrong. You should be detecting in viewDidDisappear: that your view is no longer in the interface and stopping all the activity. That's what these sorts of events are for.
If you're still bent on making certain the view controller itself is destroyed when the game is not showing, then use a different architecture. For example, present the game controller. When the game controller is dismissed, it will be released and destroyed.

View not updating before automatic Segue away from itself

Essentially I have a view controller where the user picks from three choices. Once the user chooses something, the view segues away to another view controller that displays some information regarding their choice for about 5 seconds and then segues back to original view controller automatically where the User must make more choices... (its basically a loop until something is accomplished).
The problem I am having is when the User touches their option, it seems to just segue back to itself without ever displaying the intermediary screen. I added a sleep(5); to the viewDidLoad but all that causes it to do is pause on the original choice screen for 5 seconds before segueing to itself. I also put in an NSLog in just to make sure it was actually using the new controller, which it is indeed.
I didn't include code since its so trivial. viewDidLoad on the new controller, has sleep(5) and the call to segue back to the original view controller.
I solved the problem by moving the code to viewDidAppear. Should have done that from the beginning honestly, just didn't think it through enough I guess.

Cycling through same scene on storyboard

I have a single storyboard scene that will be displayed over and over again as the user pages through data fetched from a database. When the user hits the next button, the scene segues to itself and displays the next record.
The code may not be pretty but the end result looks right, with the navigation controller handling the animation. But now that I've got it working, I'm sure it's not the right approach - I'm using a navigation controller to pop this same scene over and over, when there's no reason for the popped scene to be held in memory (data is retrieved each time it's pushed or popped).
Curious whether anyone else has done something similar and hoping for some advice on what the best approach may be. I've thought about simulating the look of the scene being popped and pushed by animating a subview - is there a third, better option? Thanks.
UPDATE
Testing has proven that the navigation controller is handling its own memory management just fine.
The view I'm working with isn't that demanding memory-wise. If anyone with a similar query has views that are, and are concerned about exceeding memory limit - this would be a good link to check out:
Memory Consumption of UINavigationController

Loading UIViews in the background on application launch

I have a simple iPad application with 5 views. On the first view, the user is asked to make some selections and set some options. From this information, the other 4 views are programatically changed after an NSNotification message is sent to them. (i.e controls are added, updated).
My problem is that when the application is first loaded, the user sees View1, but View2, View3, View4 and View5 have never been opened yet, so any changes I make programatically to those views are not done and when the user navigates to them (via the tab bar) for the first time, no changes are shown.
[EDIT: I should point out that the code for making the changes to each view is contained within the ViewController itself, and is executed when the view observes the incoming NSNotification. When the view is not loaded, it understandably never received the incoming NSNotification.]
Only after the user looks at any of those screens at least once and then goes back to View1 and makes changes, are the other Views updated properly.
I thought I could get around this issue by actively loading Views 2,3,4 and 5 into memory on application start, so that they are ready to begin receiving notifications right away.
Is there an easy way to do this in iOS 5?
Why do the view changes straight away?
I would store an indicator of the changes needed when the users answers the questions on the first view and then apply the changes on -viewDidLoad of each view that needs to be changed.
Instead of trying to load the views into memory, I'd suggest you initialize these views with the options that the user set on the first view. What I usually do in such situations, when I have a global parameters that are used in many places, I create a utility class to keep the data, make it a singleton, then access the shared instance in the viewDidLoad in the views that use the data during initialization.