Does Marking Objects As Serializable Incur Overhead?

前端 未结 1 1175
情书的邮戳
情书的邮戳 2021-02-20 15:06

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?

相关标签:
1条回答
  • 2021-02-20 15:42

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

    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)

    0 讨论(0)
提交回复
热议问题