Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

[.net] Struct alignment in memory in .NET 2.0

This topic is 4864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I saw this on MSDN - don't know if everyone's aware...the JIT now seems to lay out your type members in the defined order rather than automatically re-ordering them!
Quote:
While it may seem like a regression for the newer version of the Framework to increase the size of the type, it's actually expected behavior and a good thing that the JIT now respects the specified layout. If you'd prefer to let the JIT determine the best layout automatically (resulting in the same output as is currently generated by the 1.x JIT), you can explicitly mark your structure with a StructLayoutAttribute, specifying LayoutKind.Auto.
Here's the link Anyone want to comment before I add this attribute to my structs? [grin]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
By default, the C#, Visual Basic .NET, and C++ compilers all apply a StructLayoutAttribute to structures, specifying a Sequential layout.


I think it's a good thing that the JIT now respects the layout specified by the application. However, I fail to see what good the C# compiler does us by automatically specifying Sequential instead of Auto layouts.

Share this post


Link to post
Share on other sites
Yeah Holy Fuzz (cool name [smile]) - you want it to align all your field in size-ascending order or whatever to shrink their size and make them faster!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!