Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Given an object address on the heap, can I get the size of its header? #99

Closed
ashmind opened this issue Apr 26, 2018 · 1 comment
Closed

Comments

@ashmind
Copy link

ashmind commented Apr 26, 2018

Looking at https://blogs.msdn.microsoft.com/seteplia/2017/05/26/managed-object-internals-part-1-layout, it seems that object address on the heap points to method table, preceded by 4 or 8 byte header.

What API should I use to get this size? Currently I use IntPtr.Size, but this feels unstable in case some new implementation of CLR uses a different header format.

@leculver
Copy link
Contributor

Sorry I didn't respond to this sooner.

@ashmind The size of an object header is always the same as the pointer size in every runtime we've ever shipped. I suppose a case could be made that we should expose the object header size as a property off of ClrRuntime, but in reality there's very, very low chances that this will ever be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants