I'm pushing and pulling a lot of data from a SQLite database using my own library and perfoming data analysis/modeling of the objects in memory.
I would like to estimate on how much memory my internal data objects are currenlty using on an object-by-object or group of objects basis within the program itself. It looks like there is no simple "ruler" to give me the size of an instantiated object in bytes. I am building my own and I can easily estimate the Int/Double array storager requirements (using MemoryLayout<>.stride for these types conbined to structures).
I can't find a definition for the internal representation of the character data in a Swift String. NSString documentation is very clear and states UTF16 enconding, so I am multiplying the length by 2 to get the 8-bit btyes required for internal storage (does't not need to be perfect, just an estimate).
Does a Swift String use the same internal storage model as NSString? Or is it using UTF32? Is there are more robust way to determine the storage requirements of an individual String? And for an array of Strings? It would be awesome if there was a function like storageSizeInBtyes([String Array]) or storageSizeInBtyes(MasterDataStorageObject).