advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Although this technique is costless in terms of design, it does require some knowledge from the programmer that should really be the job of a compiler. Compilers could suggest an optimized member declaration order easily, although I'm not aware of any compiler that does so. Would you like to receive such hints from your compiler? Tell us in our C++ Discussion Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 4.1/5 | Rate this item | 13 users have rated this item.
 

Optimize Your Member Layout

Optimization doesn't have to be more trouble than it's worth! This month's solution shows a drawback-free technique that minimizes the amount of padding inserted between your data members, increasing speed and saving memory.  


advertisement
s we all know, premature optimization is considered evil as it often entails eventually useless design complications and portability compromises. However, this doesn't mean that healthy programming habits should be completely ignored, especially when they are free of charge. This month's solution shows you an effective and simple technique that will help optimize the layout of your data structures (classes, structs, and unions) without sacrificing performance or incurring any design compromises. This technique is particularly useful in applications that manipulate a large number of objects, for example databases, CAD tools, directory services, graphical editors, and financial systems. It is also useful in memory-challenged environments such as embedded systems and mobile devices.


How to pack data members optimally so that memory isn't wasted and speed isn't lost?


Organize data members in a way that minimizes the amount of padding bytes inserted between them.

  Next Page: At Sixes and Sevens
Page 1: IntroductionPage 3: Member Reordering
Page 2: At Sixes and Sevens 
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs