Closed hbmtw closed 10 years ago
Just checked with the sample app in the repository. I compiled it with Xcode 5.1 Beta 4 (the corresponding clang version) and dealloc is being called every time (Inserted a NSLog into the dealloc method of RMStepsController). But I'm pretty sure, that it is also called when compiled with Xcode 5.0.2 (the corresponding clang version). Can you give some more details? Are you sure your are using ARC?
Thanks for the fast reply. After some investigation, it seems that a "UIClassSwapper initWithCoder" is retaining a strong reference to it... now I will look into that instead.
Thanks once more :)
Hello again, I just figured out something. I think it is the UIViewcontroller category methods you have, that are causing the retain. When i run the demo project, it works just fine, and no retain, but if you add another UIViewController xtraVC, add a Button to the DemoVC and push from that button to xtraVC, then if you push to the StepsController and pop, the stepscontroller is retained and leaves a memory footprint. I have a project with the error, if you would like i can email it to u.
Could you send me that project? I would like to take a look at it ;)
besides i can see in another issue a user suggest making a change in one of the methods to avoid a retain cycle. You wrote back that, that was a good fix but have not committed it.
When i manually replace OBJC_ASSOCIATION_RETAIN_NONATOMIC with OBJC_ASSOCIATION_ASSIGN , in the above method, i get this error when pushing the modal step controller:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL numberLabel]:
Just sent you an email rm@cooperrs.de
I pushed that fix some time ago but later I found out that it causes crashes like the one you have (RMStep being released and when accessing RMStep properties a random object is called). Thus, I reverted that push.
The point here is that RETAIN_NONATOMIC is correct, as the RMStep associated with a UIViewController should be owned by that view controller or the RMStep is released as it is not owned by anyone.
I did not have the time to take a look at your example project. I will as soon as I can.
Just had a look at your example project.
The reason why no RMStep is dealloced when you press the Button in your example project is, that no RMStep is created and assigned to the UIViewController. The RMSteps is created the first time when the property is accessed. As the property is not accessed when pressing the Button, no RMSteps is alloced and thus no RMSteps will be dealloced.
Does this help?
I agere. But after pressing the Button, Then pressing back (pop out the new vc), try and push a nav steps controller (the second button in the tableview) and then pop it out. This last step controller is retained and not dealloced even after popping it out.
It is as if all view controllers in the project hold a reference to the steps controller this forcing ARC not to dealloc it. U can see memory usage under diagnostics increasing. And the retain count in instruments increasing. It is not a big issue but thought u wanted to have a look at it :) no stress :)
I have appended 3 logs at the end of this comment. The first log is the result of pushing a steps controller without tapping the additional button anytime before. The second log is the result of tapping the extra button and going back. And the third log is the result of pushing a steps controller after the additional button has been tapped. Should I see any difference in logs (1) and (3)? As in my opinion in both cases all objects are released (According to log).
If there is a memory leak I would like to find it. As I think a memory leak is a major flaw. It eats up my memory that could be used otherwise ;)...
(1) Log when tapping "Push demo process..." (without tapping "Button" before):
2014-01-29 12:41:14.487 RMStepsController-Demo[84990:70b] dealloccing rmnavsteps
2014-01-29 12:41:14.489 RMStepsController-Demo[84990:70b] dealloccing rmmodalstepscontroller
2014-01-29 12:41:14.489 RMStepsController-Demo[84990:70b] dealloccing superclass
2014-01-29 12:41:14.490 RMStepsController-Demo[84990:70b] dealloccing category
(2) Log after tapping "Button" and "Back":
2014-01-29 12:42:15.853 RMStepsController-Demo[84997:70b] dealloccing category
(3) Log when tapping "Push demo process..." (after tapping "Button")
2014-01-29 12:42:22.270 RMStepsController-Demo[84997:70b] dealloccing rmnavsteps
2014-01-29 12:42:22.271 RMStepsController-Demo[84997:70b] dealloccing rmmodalstepscontroller
2014-01-29 12:42:22.271 RMStepsController-Demo[84997:70b] dealloccing superclass
2014-01-29 12:42:22.272 RMStepsController-Demo[84997:70b] dealloccing category
It seems that the StepsController subclass is deallocated, but somethings are retained... (see attached image). The memory footprint is always increasing proportional to number of times i open and close the steps controller, but a lot of its components are retained causing the memory problem. feks the step bar and the demo vcs....
Thanks for the screenshot. Now I'm sure I see the same problem you are seeing.
Perfekt :) Dont u just love debugging! Hehe
What did the other guy end up doing? Maybe he made ASSIGN work. Worth to ask him maybe? Or u can add in the helper methods to check for kindofclass RMStepController so only this class is retained.
Hey there,
So today I took another look at the problem. I still see the problem in your example project. But I cannot reproduce the problem in the current git HEAD. Furthermore: If I copy RMStepsController, RMStepsBar and RMSteps from the current git HEAD into your example project the problem is gone.
Could you please rebuild your example project with the current git HEAD and look if there still is a problem? If there still is a problem, please send me the rebuild example project :)
Any news here?
Hello again, I tried but still it retained. I do think that in my specific example it is related to my subclass that is retaining a reference to an object that is not being released. Since, we have redesigned the app, and now use a much simpler form without steps. I appreciate your try to fix it, i will keep it in mind next time i use it to see if the problem remains :)
Hello, After dismissing the StepsController, the memory footprint is not going away (both in my app and in the sample app).
The dealloc method is never called (it should be called even in ARC).
PS: thanks for making such an awesome resource.