PX Cheng PX Cheng - 3 months ago 14
iOS Question

iOS APP,open and close a specific View each time ,Why Main function takes up close to 20M memory?

In the APP operation, I opened and closed several times a particular View, found that the incremental memory every 25MB or so, through the Allocation tool for testing and found that in each Generations main function takes up about 19MB, why main function will Occupy such a large memory? Also in the process of opening and closing a View, the main function of the implementation of what it means?

The Allocation info1

The Allocation info2

Thanks everyone!!!


The main function is the main thread which loads the UI everytime the view is reloaded. Chances are that you may have some function code specific to your app in the main thread

To free the memory overtime you close the view you can make a function which deallocates all the properties declared in the view Controller. Hope this helps

This can be done like this:

- (void)dealloc
    self.declaredProperty1 = nil;

Hope this helps.