FAQ Database Discussion Community


Objective C - Lost with retain cycles

ios,objective-c,retain-cycle
upon dismissing my VC, I noticed I am not releasing everything from memory. I'm very lost as to how I would go about finding my retain cycle. I am using an NSTimer and NSNotificationCenter, but I make sure to invalidate and removeObservers before exiting, and I made sure of using...

How does UIView prevent retain cycle?

objective-c,uiview,retain-cycle
Subview has a reference to superview, while superview also has reference (subviews) to subview. I'm wondering why this doesn't cause retain cycle?...

Do methods called from within a block need to use weakSelf?

objective-c,objective-c-blocks,retain-cycle
If the code inside a block calls a method, will a retain cycle exist if that method references self? In other words, does all code downstream of a block need to use the weakSelf/strongSelf pattern? For example: __weak __typeof__(self) weakSelf = self; Myblock block = ^{ [weakSelf doSomething]; }; ....

Retain cycle in Swift when Object A has Object B as a property and Object B has an array property that contains Object A?

ios,swift,memory-management,memory-leaks,retain-cycle
Confused about a situation that might be a retain cycle? I understand that if class Object-A { var b: Object-B } and class Object-B { var a: Object-A ] then above is horrible design because if you do var a = Object-A() var b = Object-B() a.b = b b.a...

runblock retain self reference cause memory dealloc issue

ios,swift,sprite-kit,skaction,retain-cycle
Here is my code: ship.runAction(SKAction.waitForDuration(5), completion: { self.ship.flyStraight()//retain self }) After several days googling for the memory issues, finally I found that I had a self retain in this block. When I create the new scene before the block has run, the deinit function won't be called because the reference...

Why putting “self” in the GCD blocks will cause a memory leak?

ios,block,grand-central-dispatch,autorelease,retain-cycle
I have read the great article write by benzado that using block will cause memory leak if we have a class variable retain the block itself, and the block retain "self", that cause a retain cycle. How do I avoid capturing self in blocks when implementing an API? But I...

Retain loop in a block

ios,objective-c,sprite-kit,objective-c-blocks,retain-cycle
I'm trying to get variables and properties in self in a block for actions to complete, but, if I reference self or a global variable in self when self is the object running the block, it warns me of a retain loop. Here's what I'm doing: I'm adding actions to...

Will adding the parent object of a child object to the listeners lead to a retain cycle in Node.js?

javascript,node.js,events,eventemitter,retain-cycle
I'm not really very familiar with retain cycles in Node.js coming more from Objective-C/iOS, but I wrote a bit of code that I'm hoping will not lead to a retain cycle. I'm not sure how intelligently V8 deals with garbage collection or how intelligent I'm supposed to be at this!...

retain cycle with target-selector

ios,objective-c,retain-cycle
I am new to retain cycle which I am confused if my situation falls into. I have a singleton class Singleton.h @interface Singleton : NSObject + (Singleton *)sharedInstance; - (void)doSomethingWithData:(NSDictionary *)data untilDoneReturnToTarget:(id)target selector:(SEL)selector; @end Singleton.m @implementation RequestSingleton static Singleton *shared = nil; #pragma mark - System - (id)init { self...