A compact general-purpose allocator with excellent performance.
https://microsoft.github.io/mimalloc
Add swift-mimalloc to your package dependencies and link the product in your target:
// swift-tools-version: 6.1
import PackageDescription
let package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/dataparallel-swift/swift-mimalloc.git", from: "1.1.0"),
],
targets: [
.executableTarget(
name: "MyApp",
dependencies: [
.product(name: "swift-mimalloc", package: "swift-mimalloc"),
]
)
]
)This package exposes two SwiftPM traits:
Interpose: enables malloc interposition so allocation calls are redirected to mimalloc. This trait is enabled by default.CUDA: uses CUDA pinned host memory for backing allocations. It can be combined withInterpose.
Example enabling CUDA while keeping the default Interpose trait enabled:
.package(
url: "https://github.com/dataparallel-swift/swift-mimalloc.git",
from: "1.1.0",
traits: ["CUDA", "Interpose"]
)