News for hackers. Stuff that matters.
Re:Apple’s use of Swift in iOS 12 by ppeetteerr on Friday September 28, 2018 @02:47PM (#18095942)
Not quite the same as garbage collection. When an object has a pointer null'ed, that object's reference count is reduced by 1. When the reference count reaches 0, that object is remove from memory. You could still cause memory leaks like so:

```

struct Node {

  var next: Node?

  var prev: Node?
}

var a = Node(next: nil, prev: nil)

let b = Node(next: nil, prev: a)

a.next = b

```

These two objects will persist in memory for the entire life of the app even when all reference to a and b are gone, except for their references to one another.

There are no comments on this comment yet.