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
I am trying to determine the allocated size of my generated SwiftProtobuf message types in order to see whether I could e.g. reduce their memory usage by changing the field order of smaller types inside them.
However, for types without inline storage, the _StorageClass types are fileprivate, which means that I can't easily measure their size with class_getInstanceSize.
Right now I am using the following workaround based on reflection:
I'm not aware of anything better than that. But the decisions around internal layout for size is something that's currently counted as an implementation detail and subject to change. We've had changes in this space in the past, and there are open issues about it (#735, #733). Other protobuf libraries do tweak the ordering to get better layout, it isn't something we've gone after yet for Swift, but is likely something that might eventually get some attention.
I am trying to determine the allocated size of my generated
SwiftProtobuf
message types in order to see whether I could e.g. reduce their memory usage by changing the field order of smaller types inside them.However, for types without inline storage, the
_StorageClass
types arefileprivate
, which means that I can't easily measure their size withclass_getInstanceSize
.Right now I am using the following workaround based on reflection:
Is there a better workaround for this, or should I just keep using that?
The text was updated successfully, but these errors were encountered: