Skip to content

Commit

Permalink
removed memory stress test
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarbat committed Apr 3, 2024
1 parent ec59905 commit 0237746
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions Tests/YSwiftTests/YSubscriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,4 @@ class YSubscriptionTests: XCTestCase {
subscription?.cancel()
}
}

// This causes memory to keep growing and I am not sure why
// I checked that UniFFI YSubscription struct is being dropped accordingly
// I also verified that the memory increase also happened when we used subscriptionIds and unobserve
func disabled_test_allocateTooMany() {
for i in 1...1000000000 {
_ = text.observe { _ in }

if i % 1000000 == 0 {
print("\(Date()) Iterations: \(i) Resident Size: \(residentSize() ?? 0)")
}
}

print("Done!")
}

private func residentSize() -> UInt64? {
var info = mach_task_basic_info()
let MACH_TASK_BASIC_INFO_COUNT = MemoryLayout<mach_task_basic_info>.stride/MemoryLayout<natural_t>.stride
var count = mach_msg_type_number_t(MACH_TASK_BASIC_INFO_COUNT)

let kerr: kern_return_t = withUnsafeMutablePointer(to: &info) {
$0.withMemoryRebound(to: integer_t.self, capacity: MACH_TASK_BASIC_INFO_COUNT) {
task_info(mach_task_self_,
task_flavor_t(MACH_TASK_BASIC_INFO),
$0,
&count)
}
}

guard kerr == KERN_SUCCESS else {
return nil
}

return info.resident_size
}
}

0 comments on commit 0237746

Please sign in to comment.