有没有对象标记为可序列化招致开销?开销、标记、对象、序列化

由网友(时光不老我们不散)分享简介:如果我在 [Serializable接口] 属性添加到类,这是否引入任何开销?怎么样,如果该类在任何序列化操作从未使用过?If I add the [Serializable] attribute to a class, does this introduce any overhead? How about if...

如果我在 [Serializable接口] 属性添加到类,这是否引入任何开销?怎么样,如果该类在任何序列化操作从未使用过?

If I add the [Serializable] attribute to a class, does this introduce any overhead? How about if the class is never used in any serialization operations?

推荐答案

这不任何开销增加正常运行时使用的对象。

This doesn't add any overhead to the normal runtime use of the object.

标记一类序列化甚至不导致元数据的大小不同。它只是规定了的typedef标志位。 (感谢 thecoop 指出了这一点)

Marking a class as Serializable doesn't even result in a size difference in metadata. It just sets a bit in the typedef flag. (Thanks to thecoop for pointing that out)

阅读全文

相关推荐

最新文章