Open fumoboy007 opened 2 weeks ago
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.virtualMemoryPageSize
BinaryInteger.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.
In the legacy
Foundation
module, there are a few useful memory-related functions:NSPageSize
NSRoundUpToMultipleOfPageSize
NSRoundDownToMultipleOfPageSize
Are they coming to the new
FoundationEssentials
module?