func sizeof(_: T.Type)
Returns the contiguous memory footprint of T.Does not include any dynamically-allocated or "remote" storage. In particular, sizeof(X.self), when X is a class type, is the same regardless of how many stored properties X has.
Declaration
func sizeof(_: T.Type) -> Int
You can refer to http://swiftdoc.org/v3.0/func/sizeof/#func-sizeof-t_-t-type
import Foundation
class A{
let name: float_t
let a = 4
init(name: float_t){
self.name = name
print("sdfdfs")
}
deinit{
print("sdsf")
}
}
var a = A(name: 234.45)
print(sizeof(A)) //8
let b = [2,3,4]
print(sizeofValue(b)) //8
print(sizeofValue(A)) //8
print(sizeofValue(a)) //8
网友评论