//===----------------------------------------------------------------------===// // // This source file is part of the SwiftNIO open source project // // Copyright (c) 2021 Apple Inc. and the SwiftNIO project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information // See CONTRIBUTORS.txt for the list of SwiftNIO project authors // // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// class Foo {} var allAddrs: Set = [] var iterations = 0 while true { iterations += 1 let foo = Foo() let addr = UInt(bitPattern: ObjectIdentifier(foo)) if !allAddrs.contains(addr) { if CommandLine.arguments.dropFirst().first == "debug" { print("0x", String(addr, radix: 16), separator: "") } allAddrs.formUnion([addr]) } if iterations % 100000 == 0 { let reused = iterations - allAddrs.count print("After \(iterations) iterations, we saw \(reused) reused and \(iterations - reused) fresh addresses.") } }