CLR class memory layout

允我心安 提交于 2019-12-03 06:06:31
Jon Skeet

It's implementation specific, but this article gives a description of what was present in the Microsoft .NET implementation, for CLR v2. I suspect it's the same for CLR v4, but I couldn't guarantee it. Look for a section called "ObjectInstance" for the details - but you may find the whole article interesting.

According to the article, there are basically two bits of header: the sync block which is used for locking, and the type reference which is basically a pointer to type information (including the vtable).

The original "Jit and Run" article is still around, as a chm file. Just follow the MSDN instructions to be able to read:

On most versions of windows you must first save these files to your local machine, and then unblock the file in order to read it. To unblock a file, right click on it, and select properties, and then select the ‘unblock’ button. The content will then be available to read

However, the venerable Jon Skeet guessed wrong - and object memory layout has indeed changed. Sasha Goldstein gives an up-to-date (CLR v4) survey of the layout, here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!