UIView * view = nil;
while (TRUE) {
[View removeFromSuperview];
view = [[UIView alloc] initWithFrame: self.view.bounds];
[Self.view addSubview: view];
}
I run this test code has been found in the memory is increased. In the end, where is the problem?
Reply:
Should not every realse view it.
Reply:
The ARC does not require release by
Reply:
Your example of the phenomenon has nothing to do with the ARC, this should be with the life cycle of a certain relationship.
You can build a non-ARC project, added the code, and then add the view release, as will the memory increase.
Reply:
dispatch_async (dispatch_get_main_queue (), ^ () {
UIView * view = nil;
int i = 100000;
while (i> 0) {
[View removeFromSuperview];
view = [[UIView alloc] initWithFrame: self.view.bounds];
[Self.view addSubview: view];
- I;
if (i% 1000 == 0)
{
NSLog (@ "!!!!");
}
}
}); You can try this code, running in memory kept rising after the end, the memory will come down.
So I would say that probably has a relationship with the life cycle.
Specific explanation I can not tell.
ARC I just know when to replace the manual release only.
That is, in fact, using the ARC during compilation compiler automatically add the appropriate retain, release, autorelease such as Objective-C function for each pointer variable to save the life cycle of each variable within a reasonable range, in order to achieve Automatic memory management code on.
Reply:
You can manually create an autorelease pool here. Autorelease pool is created in the default system in the main run to complete a cycle will drain again. So you can try to manually build inside the pond, pond down.
Reply:
4th Floor elaborated quite justified
Reply:
Solve the problem, looks like xcode the bug. 5.0.2 compiled with colleagues will not run memory has been increasing, but the strange thing is that I upgraded to 5.0.2. Still is a memory increase. Could it be problems with your computer?? ??
No comments:
Post a Comment