This PR implements a solution for #1282 by adding an Objective-C autorelease pool around the CoreFoundation FFI calls sysinfo uses to obtain disk information. This was chosen over a tempoary thread because spawning a thread is a much heavier operation (shared memory, stack allocations, etc). It also seems better then a worker thread because longer-lived apps that don't call this operation much might not want an extra thread living forever. In addition to all these approaches, if people are using sysinfo code in a traditional cocoa app then this thread would be extra pointless as the built-in runloops would be clearing autorelease'd values out already.
In the future this pool could be moved to a more reusable context to support multiple refreshes before draining, but this is a performance issue and not a correctness one. Therefore, it is left as future work.
This PR implements a solution for #1282 by adding an Objective-C autorelease pool around the
CoreFoundation
FFI callssysinfo
uses to obtain disk information. This was chosen over a tempoary thread because spawning a thread is a much heavier operation (shared memory, stack allocations, etc). It also seems better then a worker thread because longer-lived apps that don't call this operation much might not want an extra thread living forever. In addition to all these approaches, if people are usingsysinfo
code in a traditional cocoa app then this thread would be extra pointless as the built-in runloops would be clearing autorelease'd values out already.In the future this pool could be moved to a more reusable context to support multiple refreshes before draining, but this is a performance issue and not a correctness one. Therefore, it is left as future work.
Closes #1282