# Huge performance hit from exclusive memory access checks

**URL:** <https://forums.swift.org/t/huge-performance-hit-from-exclusive-memory-access-checks/54374>\
**Category:** Using Swift\
**Tags:** performance, memory-safety\
**Created:** [December 31, 2021, 5:41pm UTC](https://forums.swift.org/t/huge-performance-hit-from-exclusive-memory-access-checks/54374 "2021-12-31T17:41:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [December 31, 2021, 8:31pm UTC](https://forums.swift.org/t/huge-performance-hit-from-exclusive-memory-access-checks/54374/3 "2021-12-31T20:31:19Z")

</div>

Putting an array inside a class is indeed going to pessimize your performance. You may find the following thread and the links there to be helpful:

> [@Low-level swift optimization tips](https://forums.swift.org/t/low-level-swift-optimization-tips/37917):
>
> The past few days i’ve been working on a pure-Swift implementation of [lz77 inflate](https://tools.ietf.org/html/rfc1951) and getting its performance on-par with that of the system-installed libz, so that i can remove the system dependency from Swift PNG. i learned a lot about what works and what doesn’t when it comes to optimizing algorithms implemented in swift, that is specific to the language and that i figured could help other people working on similar frameworks so i wrote up some of my findings for reference. i’m not really a…

---

_[View the full topic](https://forums.swift.org/t/huge-performance-hit-from-exclusive-memory-access-checks/54374)._
