You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to obtain free disk space size through the example code in the document below, but it seems that memory leak occurs when using all api related to URLResourceKey. Running with instrument, it seems that objects such as CFString are not released inside Foundation.
while (true) {
let fileURL = URL(fileURLWithPath:"/")
do {
let values = try fileURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey])
if let capacity = values.volumeAvailableCapacityForImportantUsage {
print("Available capacity for important usage: \(capacity)")
} else {
print("Capacity is unavailable")
}
} catch {
print("Error retrieving capacity: \(error.localizedDescription)")
}
}
The text was updated successfully, but these errors were encountered:
Wrapping the do/catch in an autoreleasepool prevents the memory leak, but we should fix this internally. I'll forward this to the responsible team, thanks for filing!
Actually, I want to use above code in objective-c side. In swift, it's possible to prevent memory leakage by wrapping with autoreleasepool, but objective-c can't prevent it with the @autoreleasepool.
When I try to obtain free disk space size through the example code in the document below, but it seems that memory leak occurs when using all api related to URLResourceKey. Running with instrument, it seems that objects such as CFString are not released inside Foundation.
https://developer.apple.com/documentation/foundation/urlresourcekey/checking_volume_storage_capacity
example)
The text was updated successfully, but these errors were encountered: