1

For the purpose of this question, let us say that I have a class that represents any given type of data. The objects of these classes can "connect" to one another in order to form a network.

class DataObject
{
    var value: Any?

    var connectedObjects = [DataObject]()

    func connectToObject(object: DataObject)
    {
        connectedObjects.append(object)
    }
}

From what I understand, Swift arrays retain objects. In the event of multiple, interlinked DataObject instances, does retainership provide any scope for performance degradation / memory leaks? And what is this particular problem pattern known as?

Vatsal Manot
  • 17,695
  • 9
  • 44
  • 80

1 Answers1

0

Yes. The issue is called a "retain cycle" and results in a memory leak.

Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200