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

Allocated size of object #29

Open
sharwell opened this issue Nov 23, 2014 · 2 comments
Open

Allocated size of object #29

sharwell opened this issue Nov 23, 2014 · 2 comments

Comments

@sharwell
Copy link
Member

I would be interested in a combination of an analyzer and Visual Studio extension which estimates the size of an object when allocated. While the CLR is allowed to change the layout of types, a basic set of rules should be able to provide a good reference for the size of the object in most cases.

The analyzer would use the DiagnosticSeverity.Hidden flag, and then the data could be shown to the user via a Visual Studio extension that updates the Code Lens data associated with the type definition.

@ilmax
Copy link

ilmax commented Jan 18, 2015

+1

@pharring
Copy link

pharring commented May 7, 2015

I like the idea. I've often wanted something like that myself. But it's tricky.
Some thoughts:

  • Has to display the size assuming either a 32-bit or 64-bit runtime (i.e. reference type fields are pointer-sized).
  • Generics? Should the result be expressed in terms of the size of unconstrained generic arguments?
  • Has to know about backing fields created for auto-properties
  • Has to traverse all base types, nested types, arrays, generic instantiations, etc.
  • Has to honor explicit struct layout
  • Has to make assumptions about the CLR's packing algorithm for auto-layout

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

No branches or pull requests

3 participants