About Using the removeFromParentViewController to Release

Asked 2 years ago, Updated 2 years ago, 51 views

This is my first time using this place.

I am currently developing a game using xcode6 objective-c.

Memory release is not working.

After transitioning from viewcontroller A to viewcontroller B

I am using dispatchViewControllerAnimated in B.

Memory has not changed since returning to viewcontroller A.

Even if you removeFromSuperview everything you declared as an instance,
Only about 20 percent of the total was released.


after returning from B to A using the dismissViewControllerAnimated If you transition from A to B again,
Bad_access will appear in various places with some variables remaining.


when using dismissViewControllerAnimated Release all contents of viewcontroller B and
After transitioning from A to B again, I would like to read from 1
Can't you do something about it?

I may not be able to explain enough, but I appreciate your cooperation.

objective-c

2022-09-30 14:41

1 Answers

There seems to be a misunderstanding about the timing of the View Controller's memory release, so let me check.
Modally displayed View Controllers are released from memory when dismissViewControllerAnimated: is completed, or removeFromSuperview will not be released.
To verify this, try writing the dealloc() method in viewcontroller B.

-(void)dealloc{
    NSLog(@"ViewController B instance was released.");
}

When you run dismissViewControllerAnimated: with viewcontroller B as the receiver, the console immediately prints VViewController B instance was released. /

A common case is circulation reference when the modal display is terminated but the memory is not released as expected.If you search the Internet with keywords such as Objective-c ARC circular reference, you will be able to find information in Japanese about circular reference.Of course, if you're directly involved in Apple's official documentation, it's no better than that.


2022-09-30 14:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.