# Use of @convention(thin) to avoid allocating closures

**URL:** <https://forums.swift.org/t/use-of-convention-thin-to-avoid-allocating-closures/12087>\
**Category:** Using Swift\
**Created:** [April 23, 2018, 2:11pm UTC](https://forums.swift.org/t/use-of-convention-thin-to-avoid-allocating-closures/12087 "2018-04-23T14:11:53Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [April 24, 2018, 4:29pm UTC](https://forums.swift.org/t/use-of-convention-thin-to-avoid-allocating-closures/12087/6 "2018-04-24T16:29:15Z")

</div>

`@convention(thin)` is not officially supported yet and may cause compiler crashes if not used in the narrow circumstances it happens to work by accident today. If a closure truly closes over no state, its context pointer should be null, and retain/release operations should early-exit on it. There'll be some code size and branching overhead from this, but shouldn't be any atomic memory access overhead, at least. If your signatures happen to be C-compatible, you might be able to use `@convention(c)` instead, which is more completely implemented.

---

_[View the full topic](https://forums.swift.org/t/use-of-convention-thin-to-avoid-allocating-closures/12087)._
