类存储在内存中 [英] Class storage in memory

查看:96
本文介绍了类存储在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对象如何存储在内存中?

属性(公共/私有)是否与方法分开存储?

(即除执行代码之外的数据,即方法定义IL代码的一个副本)

或捆绑包分别存储(即数据和方法IL代码一起存储).

如果您需要存储很多对象,而后者是正确的,那么这可能会占用大量内存,因此分离数据并具有纯数据对象和一个数据处理程序代码将是有益的.

How is a object stored in memory?

Are the properties (public/private) stored apart from the methods

(i.e. data apart from the executing code, one copy of the method definition IL code)

Or bundles are stored separately (i.e. data and method IL code stored together).

This could have huge memory implications if you need to store a lot of objects and the latter is correct so it would be beneficial to separate the data and have pure data objects and one data handler code.

推荐答案

方法存储一次-您无需更改它们,因此它们实际上是静态对象:每个类仅一个实例.
Methods are stored once - you don''t change them so they are effectively static objects: only one instance per class.


这篇关于类存储在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆