# \#weak

**URL:** https://forums.swift.org/tag/weak/301.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Allow closure to be statically isolated to a weakly captured actor](https://forums.swift.org/t/allow-closure-to-be-statically-isolated-to-a-weakly-captured-actor/85451)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 15\
**Last updated:** [March 25, 2026, 12:40am UTC](https://forums.swift.org/t/allow-closure-to-be-statically-isolated-to-a-weakly-captured-actor/85451 "2026-03-25T00:40:53Z")

</div>

Right now, you can write an API that allows an actor to call it and pass in a closure that is statically isolated to the calling actor: final class Foo { func onWrite(\_ callback: @escaping () async -\> ()) { …

---

## [Unnecessary self weak dance](https://forums.swift.org/t/unnecessary-self-weak-dance/84536)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 3\
**Last updated:** [February 5, 2026, 7:52am UTC](https://forums.swift.org/t/unnecessary-self-weak-dance/84536 "2026-02-05T07:52:50Z")

</div>

I saw this pattern which in a distilled form is equivalent to: struct S { init(closure: () -\> Void) {} } class C { func foo() -\> S { S { \[weak self\] in guard let self else { return } …

---

## [What guarantees does Swift provide regarding weak references?](https://forums.swift.org/t/what-guarantees-does-swift-provide-regarding-weak-references/82804)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 7\
**Last updated:** [January 9, 2026, 8:10pm UTC](https://forums.swift.org/t/what-guarantees-does-swift-provide-regarding-weak-references/82804 "2026-01-09T20:10:54Z")

</div>

Are the guarantees that Swift offers about weak references spelled out somewhere official? If not, could someone on the core team tell me in this thread what is guaranteed? For example, consider this code: class Foo { …

---

## [\[Accepted\] SE-0481: \`weak let\`](https://forums.swift.org/t/accepted-se-0481-weak-let/79895)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 15\
**Last updated:** [November 9, 2025, 10:43am UTC](https://forums.swift.org/t/accepted-se-0481-weak-let/79895 "2025-11-09T10:43:44Z")

</div>

Hello, Swift community. The review of SE-0481: weak let ran from April 30th through May 13th, 2025. Feedback was generally positive. Some reviewers expressed concern about a perceived shift in the meaning of let that …

---

## [Is the implicit \`self\` passed to instance methods always strongly retained?](https://forums.swift.org/t/is-the-implicit-self-passed-to-instance-methods-always-strongly-retained/82301)

<div class="topic-metadata">

**Author:** [@winstondu](https://forums.swift.org/u/winstondu)\
**Replies:** 13\
**Last updated:** [September 23, 2025, 9:37pm UTC](https://forums.swift.org/t/is-the-implicit-self-passed-to-instance-methods-always-strongly-retained/82301 "2025-09-23T21:37:32Z")

</div>

This is an almost “trivial” thing (and I think we all know the answer), but even after hours of digging, I’m surprised I found absolutely NO clearly stated guarantee in the Swift language official specification about th…

---

## [SE-0481: \`weak let\`](https://forums.swift.org/t/se-0481-weak-let/79603)

<div class="topic-metadata">

**Author:** [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Replies:** 25\
**Last updated:** [May 14, 2025, 6:24pm UTC](https://forums.swift.org/t/se-0481-weak-let/79603 "2025-05-14T18:24:26Z")

</div>

Hello, Swift community. The review of SE-0481: weak let begins now and runs through May 13th, 2025. Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum threa…

---

## [Weak captures in sendable/sending closures](https://forums.swift.org/t/weak-captures-in-sendable-sending-closures/78498)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 20\
**Last updated:** [April 15, 2025, 8:41am UTC](https://forums.swift.org/t/weak-captures-in-sendable-sending-closures/78498 "2025-04-15T08:41:50Z")

</div>

Consider the following example: final class X: Sendable { func bar() {} } func doIt(\_ block: () -\> Void) { block() } func foo() { let x = X() doIt { \[weak x\] in Task { // error: passing closure…

---

## [Efficiently Reaping Weak Collections](https://forums.swift.org/t/efficiently-reaping-weak-collections/78205)

<div class="topic-metadata">

**Author:** [@bdkjones](https://forums.swift.org/u/bdkjones)\
**Replies:** 7\
**Last updated:** [March 1, 2025, 10:25pm UTC](https://forums.swift.org/t/efficiently-reaping-weak-collections/78205 "2025-03-01T22:25:17Z")

</div>

Context: I have a ModelController that keeps a collection of weak references to ModelObjects. The controller receives changes from the cloud and, for each one, sees if the change affects a ModelObject in the collection. …

---

## [Imbricated sending closures & weak self](https://forums.swift.org/t/imbricated-sending-closures-weak-self/77449)

<div class="topic-metadata">

**Author:** [@bioche](https://forums.swift.org/u/bioche)\
**Replies:** 2\
**Last updated:** [January 25, 2025, 9:50pm UTC](https://forums.swift.org/t/imbricated-sending-closures-weak-self/77449 "2025-01-25T21:50:12Z")

</div>

Hello Swift community ! Just a question about a small detail. I have the following code that triggers a concurrency warning : final class Foo: Sendable { func bar() { Task { \[weak self\] in Task …

---

## [Can I use weak to check for retain cycles?](https://forums.swift.org/t/can-i-use-weak-to-check-for-retain-cycles/72591)

<div class="topic-metadata">

**Author:** [@dannys42](https://forums.swift.org/u/dannys42)\
**Replies:** 6\
**Last updated:** [September 4, 2024, 5:51am UTC](https://forums.swift.org/t/can-i-use-weak-to-check-for-retain-cycles/72591 "2024-09-04T05:51:29Z")

</div>

I've got a class that initializes some blocks and such, and want to ensure I don't have any retain cycles. I'm attempting to write a unit test to verify some simple cases, like this: func testThat\_MyClass\_WillRelease()…

---

## [\`weak var\` in \`Sendable class\`](https://forums.swift.org/t/weak-var-in-sendable-class/71512)

<div class="topic-metadata">

**Author:** [@KeithBauerANZ](https://forums.swift.org/u/KeithBauerANZ)\
**Replies:** 2\
**Last updated:** [April 29, 2024, 3:45am UTC](https://forums.swift.org/t/weak-var-in-sendable-class/71512 "2024-04-29T03:45:35Z")

</div>

So, I was making a class, right: final class C: Sendable {} final class X: Sendable { weak var c: C? init(c: C) { self.c = c } } But the compiler goes Stored property 'a' of 'Sendable'-conforming…

---

## [About nesting function and implicit capture](https://forums.swift.org/t/about-nesting-function-and-implicit-capture/70834)

<div class="topic-metadata">

**Author:** [@Saafo](https://forums.swift.org/u/Saafo)\
**Replies:** 1\
**Last updated:** [March 22, 2024, 12:04pm UTC](https://forums.swift.org/t/about-nesting-function-and-implicit-capture/70834 "2024-03-22T12:04:48Z")

</div>

I'm using a nesting function C.f.ff, and I'm wondering that is this a implicit strong capture of self.v? how can we declare a weak capture? import Foundation class C { var v: Int = 0 func f() { func ff(…

---

## [Cannot find 'weak' in scope on closure of a DispatchQue.async](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819)

<div class="topic-metadata">

**Author:** [@richoncode](https://forums.swift.org/u/richoncode)\
**Replies:** 4\
**Last updated:** [February 8, 2024, 3:33am UTC](https://forums.swift.org/t/cannot-find-weak-in-scope-on-closure-of-a-dispatchque-async/69819 "2024-02-08T03:33:38Z")

</div>

let concurrentQueue = DispatchQueue(label: "concurrentQueue", qos: .background, attributes: .concurrent) concurrentQueue.async { \[weak self\] // Cannot find 'weak' in scope guard let self = self else { return } } I v…

---

## [Special syntax for blocks that capture all variables as weak](https://forums.swift.org/t/special-syntax-for-blocks-that-capture-all-variables-as-weak/49290)

<div class="topic-metadata">

**Author:** [@eventomer](https://forums.swift.org/u/eventomer)\
**Replies:** 18\
**Last updated:** [February 1, 2024, 10:29pm UTC](https://forums.swift.org/t/special-syntax-for-blocks-that-capture-all-variables-as-weak/49290 "2024-02-01T22:29:07Z")

</div>

Introduction Introducing a special syntax for blocks who capture all variables as weak. For example: publisher.sink {? self.update(button) } Will be equivalent to publisher.sink { \[weak self, weak button\] in guar…

---

## [Can a group of weak references conform to Collection?](https://forums.swift.org/t/can-a-group-of-weak-references-conform-to-collection/65899)

<div class="topic-metadata">

**Author:** [@bbrk24](https://forums.swift.org/u/bbrk24)\
**Replies:** 4\
**Last updated:** [June 30, 2023, 7:32am UTC](https://forums.swift.org/t/can-a-group-of-weak-references-conform-to-collection/65899 "2023-06-30T07:32:00Z")

</div>

I have a type that collects weak references, which you can iterate over and append to. I want it to conform to RangeReplaceableCollection, but I don't think I can do anything more specific than Sequence. The type itself…

---

## [Override weak var](https://forums.swift.org/t/override-weak-var/65230)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 0\
**Last updated:** [May 28, 2023, 12:30am UTC](https://forums.swift.org/t/override-weak-var/65230 "2023-05-28T00:30:51Z")

</div>

These examples: class Foo { weak var v: AnyObject? } class Bar: Foo { override weak var v: AnyObject? { get { super.v } set { super.v = newValue } } } class Baz: Foo { override weak var…

---

## [Weak reference doesn't work as expected when passing it to a function's argument](https://forums.swift.org/t/weak-reference-doesnt-work-as-expected-when-passing-it-to-a-functions-argument/64432)

<div class="topic-metadata">

**Author:** [@vigdora](https://forums.swift.org/u/vigdora)\
**Replies:** 4\
**Last updated:** [April 18, 2023, 7:39am UTC](https://forums.swift.org/t/weak-reference-doesnt-work-as-expected-when-passing-it-to-a-functions-argument/64432 "2023-04-18T07:39:38Z")

</div>

I am already aware of the strong/weak reference concept in swift. yet after running the next code, and tapping on the Button (and dismissing the screen), the TestViewModel stayed in memory! I was expecting that using \[…

---

## [Lifetime of object when using withCheckedContinuation and weak var](https://forums.swift.org/t/lifetime-of-object-when-using-withcheckedcontinuation-and-weak-var/63027)

<div class="topic-metadata">

**Author:** [@Tunous](https://forums.swift.org/u/Tunous)\
**Replies:** 1\
**Last updated:** [February 8, 2023, 1:51pm UTC](https://forums.swift.org/t/lifetime-of-object-when-using-withcheckedcontinuation-and-weak-var/63027 "2023-02-08T13:51:02Z")

</div>

I’m wondering about lifetime of an object that is passed through withCheckedContinuation function to a weak variable. Is there any guarantee that the passed object won’t be deallocated until after withCheckedContinuation…

---

## [Is there any static analysis tool which can help us detect memory leak cause by missing \[weak self\]?](https://forums.swift.org/t/is-there-any-static-analysis-tool-which-can-help-us-detect-memory-leak-cause-by-missing-weak-self/60558)

<div class="topic-metadata">

**Author:** [@yccheok](https://forums.swift.org/u/yccheok)\
**Replies:** 1\
**Last updated:** [September 29, 2022, 11:49am UTC](https://forums.swift.org/t/is-there-any-static-analysis-tool-which-can-help-us-detect-memory-leak-cause-by-missing-weak-self/60558 "2022-09-29T11:49:12Z")

</div>

I was wondering, is there any tool, which can help to detect memory leak caused by missing \[weak self\]. For instance, the following code contains memory leak issue caused by lack of \[weak self\] class ImagePageViewContr…

---

## [Weak self reference vs strong member reference performance](https://forums.swift.org/t/weak-self-reference-vs-strong-member-reference-performance/57530)

<div class="topic-metadata">

**Author:** [@jjatie](https://forums.swift.org/u/jjatie)\
**Replies:** 3\
**Last updated:** [May 23, 2022, 6:36pm UTC](https://forums.swift.org/t/weak-self-reference-vs-strong-member-reference-performance/57530 "2022-05-23T18:36:32Z")

</div>

What are the tradeoffs between capturing self weakly vs capturing a member on self strongly. Are there performance tradeoffs for strong vs weak captures? Given the class below, are options 1 and 2 equivalent, or are the…

---

## [Why is implicit \`\[weak self\]\` not the norm?](https://forums.swift.org/t/why-is-implicit-weak-self-not-the-norm/49232)

<div class="topic-metadata">

**Author:** [@GabrielBrodersen](https://forums.swift.org/u/GabrielBrodersen)\
**Replies:** 19\
**Last updated:** [June 9, 2021, 1:48am UTC](https://forums.swift.org/t/why-is-implicit-weak-self-not-the-norm/49232 "2021-06-09T01:48:36Z")

</div>

After browsing the web for this question and learning about memory retain cycles in Swift (and how to deal with them), it is easy to get the impression that adding the capture list \[weak self\] is often the solution and r…

---

## [Does autoclosure respect weak'ness of a captured variable?](https://forums.swift.org/t/does-autoclosure-respect-weakness-of-a-captured-variable/39724)

<div class="topic-metadata">

**Author:** [@Kentzo](https://forums.swift.org/u/Kentzo)\
**Replies:** 2\
**Last updated:** [November 12, 2020, 7:23pm UTC](https://forums.swift.org/t/does-autoclosure-respect-weakness-of-a-captured-variable/39724 "2020-11-12T19:23:13Z")

</div>

I'm confused whether in the following example the weakInstance autoclosure captures self weakly and can therefore return nil: func perform(weakInstance: @autoclosure () -\> SomeType?) { weakInstance() // \<- Can this…

---

## [Hashing Weak Variables](https://forums.swift.org/t/hashing-weak-variables/31345)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 19\
**Last updated:** [December 5, 2019, 9:01pm UTC](https://forums.swift.org/t/hashing-weak-variables/31345 "2019-12-05T21:01:13Z")

</div>

I'm trying to make a wrapper (property delegate) that would encapsulate how weak references should be compared and hashed. Consider this example: class MyClass { } struct WeakRef: Hashable { weak var ref: MyClass?…
