<!--
{
  "availability" : [
    "Swift: 6.2.0 -",
    "Xcode: 26.0.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Attachable/estimatedAttachmentByteCount",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Swift Testing"
    ],
    "preciseIdentifier" : "s:7Testing10AttachableP28estimatedAttachmentByteCountSiSgvp"
  },
  "title" : "estimatedAttachmentByteCount"
}
-->

# estimatedAttachmentByteCount

An estimate of the number of bytes of memory needed to store this value as
an attachment.

```
var estimatedAttachmentByteCount: Int? { get }
```

## Discussion

The testing library uses this property to determine if an attachment
should be held in memory or should be immediately saved. Larger
attachments are more likely to be saved immediately, but the algorithm the
testing library uses is an implementation detail and is subject to change.

The value of this property is approximately equal to the number of bytes
that will actually be needed, or `nil` if the value cannot be computed
efficiently. The default implementation of this property returns `nil`.

> Complexity: O(1) unless `Self` conforms to `Collection`, in which case
> up to O(*n*) where *n* is the length of the collection.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)