1.

In Swift, how would you describe a circular reference? What are your options for resolving it?

Answer»

When two instances have a strong connection to one other, a circular REFERENCE occurs, resulting in a memory leak because neither of the two instances will ever be deallocated. The reason for this is that you can't deallocate an INSTANCE if it has a strong reference to it, yet each instance maintains the other alive due to the strong reference. This might LEAD to a deadlock which is EXTREMELY bad for the application.

Breaking the strong circular reference by replacing one of the strong references with a weak or unowned reference would fix the problem of a circular reference.



Discussion

No Comment Found