Questions tagged [strong-references]

Strong references are regular references that are protected from garbage collection, in contrast to weak references.

Strong references are regular references that are protected from garbage collection, in contrast to .

86 questions
0
votes
2 answers

iOS dismissing a view controller doesn't release memory

I know it's all with the weak strong reference when presenting the viewController in the parent view ... correct me please if I'm wrong this is an example how I do it let viewHolder = viewClass() func presentView() { self.present(viewHolder,…
0
votes
0 answers

GCD keeps strong reference to 'self' even when defining a capture list

class MyClass { var someProperty = 0 deinit { // never gets called } func doSomething() { DispatchQueue.global().async { [weak self] in Thread.sleep(forTimeInterval: 3600) self?.someProperty…
bcause
  • 1,303
  • 12
  • 29
0
votes
1 answer

Converting a strong reference to weak reference to self

How do you convert this to a weak reference to self? NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyViewController.handleMessage(_:)), name: "NewMessage", object:…
Prabhu
  • 12,995
  • 33
  • 127
  • 210
0
votes
3 answers

Will a strong reference to a subview in a dictionary cause a reference cycle?

I have a view with variable subviews, the subviews are set up using a enum describing the type of this subview. My question is if the following would cause a strong reference cycle or if there is a better way to do this: class ControlBar: UIView { …
twiz_
  • 1,178
  • 10
  • 16
0
votes
0 answers

UIViewController loop strong reference doesn't prevent dealloc

I am using ARC. The case of study here inculdes a custom UITabBarController and one of its UIViewControllers. The Tabbar have a strong reference to an Object of some class. That object also have a strong reference to the Tabbar itself which caused…
hasan
  • 23,815
  • 10
  • 63
  • 101
0
votes
1 answer

C++ - How to break when the number of references to a shared pointer change?

In Microsoft Visual C++ 2015, how can I set a "Data Breakpoint" on a Boost shared pointer so that the debugger breaks whenever the number of strong and/or weak references changes?
Pietro
  • 12,086
  • 26
  • 100
  • 193
0
votes
2 answers

How is a strong retain cycle possible with async or static calls?

I am trying to grasp how I can recognize when a strong retain cycle is possible and requires me to use [weak/unowned self]. I've been burned by unnecessarily using [weak/unowned self] and the self was deallocated immediately before giving me a…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
0
votes
1 answer

Is there a way to turn a weak reference into a strong one?

I have an object that is set as the delegate of another object, whose delegate property is weak. - (YYService *)service { XXHandler *handler = [[XXHandler alloc] init]; // YYService's "delegate" property is weak return [[YYService alloc]…
ide
  • 19,942
  • 5
  • 64
  • 106
0
votes
1 answer

when strong reference directly access weak reference

In Java, when an target object A is only reached by weak reference B, A can be GC. what happen if the weak reference B is reached by a strong reference C at same time? For exmaple, C points to a class instance which contains a field of weak…
0
votes
2 answers

When to create an outlet of strong type?

When we create an outlet its property is directly set to a weak type. However weak type contains on optional value. I want outlet created to be of strong type so that it always contains a value. But there is memory management issues and can form…
user4790024
0
votes
1 answer

break strong reference cycle between Managed Object and Collectionview Cell

Update : Had nothing to do with Core Data or the CollectionView. I never dismissed the ViewController holding the CollectionView. More in the answer below! I am having a memory leak in Swift iOS. First I thought it was located in my fetch function,…
R Menke
  • 8,183
  • 4
  • 35
  • 63
0
votes
0 answers

Are Action and Func passed as strong references?

I have a Register Callback method on a Game class that objects can register a callback with for when the game is shutting down. public void RegisterAsyncShutdownCallback(Func callback) { if (this.asyncShutdownCallbacks.Contains(callback)) …
Johnathon Sullinger
  • 7,097
  • 5
  • 37
  • 102
0
votes
2 answers

pushed ViewController won't dealloc. which strong reference holds it?

I have a ViewController like below; All of the delegates are weak, what else can it be a strong reference then ? I can't get it, and the ViewController won't dealloc that is really bad.
anna
  • 662
  • 5
  • 28
0
votes
1 answer

Objective-C++ and objects retaining

Consider this code example: class SomeArbitrarilyNamedClassPlusPlus { public: SomeArbitrarilyNamedClassPlusPlus(NSObject *object) { object_ = object; } SomeArbitrarilyNamedClassPlusPlus() { object_ = nil; } private: NSObject…
peetonn
  • 2,942
  • 4
  • 32
  • 49
0
votes
2 answers

IOS about weak and strong, what's the result should be? and constant declare

there are two properties like below #import @interface Contact : NSObject @property(nonatomic, strong)NSDate *birthDay; @property(nonatomic, weak)NSDate *birthDay1; - (void)testWeakProperty; @end on implementation…
maple
  • 101
  • 1
  • 13