Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap