How to resolve a memory failure

I am creating an application that has several animations. There are 50 pages, and each page has a different animation, and each animation uses a lot of images.

I am using UIPresentModelViewController to represent presentations and changing images using NSTimer .

When continuously scrolling through an application with this message: -

 Program received signal: "0". Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib") 

I searched a lot, but did not find suitable solutions for this problem.

+7
source share
8 answers

Just check inside your code that you are making some kind of mistake by adding a new view every time, but forgot to free it ...

0
source

You need to see (and possibly publish) the stack trace on failure. And the code that changes the image. It sounds like a memory bloat (not a real leak in the fact that someone is still referring to the memory). The Analysis menu item may catch something (and you should definitely run it), but you may need to run the Distribution tool and look at the heap checks. For more details see http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth / .

0
source

It sounds like a stack overflow for me. In the "Other C flags" section of the C / C ++ project language settings, add the "-fstack-check" flag and see if any unwanted recursion occurs.

0
source

Signal 0 is usually associated with low memory because the application uses too much memory. Check if the memory alert method is called.

Data formatting error cannot be caused by insufficient memory to load it.

0
source

50 views, as you describe, sounds like a great god of memory. Therefore, I suspect that memory management unloads some kinds. Then, when your program needs presentations, they are not there, and your program will fail. The error message does not quite match this, but it may not be accurate to tell you what the problem is.

Consider the following possible scenario and see if it is suitable for encoding this program.

In order for the OS to manage memory, it can unload views and reload them as needed. When this is done, the methods viewDidUnload, loadView, and viewDidLoad are called.

viewDidUnload:

This method is called as an analog of the viewDidLoad method. It is called during low memory conditions when the view manager needs to free its view and any objects associated with this view in order to free memory. Because view controllers often store references to views and other objects associated with the view, you should use this method to relinquish ownership of these objects so that their memory can be recovered. You should only do this for objects that you can easily recreate later, either in the viewDidLoad method or from other parts of your application. You should not use this method to release user data or any other information that cannot be easily recreated.

loadView:

The view controller calls this method when it requests a view property, but it is currently zero. If you create your views manually, you must override this method and use it to create your views. If you use Interface Builder to create your views and initialize the view controller, that is, you initialize the view using the initWithNibName: bundle method: directly set the nibName and nibBundle properties or create both views and the view controller in the Builder interface, then you should not override this method .

Check out the link to the UIView class -

viewDidLoad:

This method is called after the view controller has loaded the views associated with it into memory. This method is called whether the views were saved in the nib file or created programmatically in the loadView method. This method is most often used to perform additional steps to initialize views loaded from nib files.

You may have unintentionally initialized these views in your init methods, not your loadView methods. If you do this, then when the OS unloads the view (you will see viewDidUnload), the memory associated with the view and all sub-items (all images and animations) will be unloaded. This saves memory, but when you need one of these unloaded views to reappear, loadView will be called first if the view was previously unloaded. If view customization is done in init methods and not in loadView, the view will not be configured again. But if the view is set up in the loadView method, it can be restored after memory management unloads it.

0
source

There is one simple way to find out leaks that are difficult to find with leak tools, etc. - zombie analyzer. It shows every unconnected memory in your program, and you can easily detect leaks and optimize your code in minutes.

0
source

If you use many images for one animation, you are doing it wrong. You should have one or more very large images, and then just show part of that image. Thus, you can upload very few images, but have the same effect on the availability of many images.

Look at cocos2d or other frameworks that are popular for creating games, as they will be much more effective for animations than just UIKit.

0
source

Find out the cause of the memory failure with the tool tool, and then reorganize the code using best practices with the recommended design pattern. There is no single solution for this. Thanks.

0
source

All Articles