<!--
{
  "availability" : [
    "Mac Catalyst: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Compression",
  "identifier" : "/documentation/Compression/COMPRESSION_LZMESH",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "Compression"
    ],
    "preciseIdentifier" : "c:@EA@compression_algorithm@COMPRESSION_LZMESH"
  },
  "title" : "COMPRESSION_LZMESH"
}
-->

# COMPRESSION_LZMESH

The LZMESH compression algorithm, which is recommended for fast, general-purpose compression on Apple platforms.

```
var COMPRESSION_LZMESH: compression_algorithm { get }
```

## Discussion

LZMESH is the Apple general-purpose compression algorithm, designed to replace both [`COMPRESSION_LZFSE`](/documentation/Compression/COMPRESSION_LZFSE) and [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) across Apple platforms. It combines LZ77 with length-limited Huffman coding and a lazy match parser to deliver better compression ratio than both [`COMPRESSION_LZFSE`](/documentation/Compression/COMPRESSION_LZFSE) and [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) while encoding significantly faster than either. LZMESH decodes 3.5x faster than [`COMPRESSION_ZLIB`](/documentation/Compression/COMPRESSION_ZLIB) on Apple silicon.

An LZMESH-encoded buffer is a sequence of blocks terminated by an end-of-stream marker. There are three block types:

- Raw block: A header followed by uncompressed bytes. The encoder emits raw blocks when the data is incompressible, so the output is never significantly larger than the input.
- Compressed block: A header followed by LZMESH-encoded data. Each block can represent up to 4 GB of uncompressed content.
- End-of-stream block: A single-byte marker that terminates the stream.

Each compressed block includes a footer that records block encoding parameters. Both headers and footers reserve flag bits for future format extensions.

LZMESH is available through the buffer API only — [`compression_encode_buffer(_:_:_:_:_:_:)`](/documentation/Compression/compression_encode_buffer(_:_:_:_:_:_:)) and [`compression_decode_buffer(_:_:_:_:_:_:)`](/documentation/Compression/compression_decode_buffer(_:_:_:_:_:_:)).

The decoder requires only 64 KB of scratch memory, making it well suited for memory-constrained environments.

> Note: The `COMPRESSION_LZMESH` algorithm is available in version 27 or later of Apple operating systems.

---

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)