swift-foundation
swift-foundation copied to clipboard
Missing `NSPageSize` and related functions
In the legacy Foundation module, there are a few useful memory-related functions:
Are they coming to the new FoundationEssentials module?
We likely won't want to bring these static functions as-is into swift-foundation as they don't really fit into Swift nicely. We could instead consider adding page size as an API to, say, ProcessInfo, since it currently has OS-level API such as physicalMemory?
Good idea!
Perhaps the following names:
ProcessInfo.virtualMemoryPageSizeBinaryInteger.round(_:toMultipleOf:)BinaryInteger.rounded(_:toMultipleOf:)
Using the rounding APIs would look like
var bytes = …
bytes.round(.up, toMultipleOf: ProcessInfo.processInfo.virtualMemoryPageSize)
Not sure if the rounding APIs should live in Foundation though or somewhere else.