advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Which other memory allocation policies do your applications necessitate? How do you enforce these policies? Let us know in our C++ Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 4.7/5 | Rate this item | 3 users have rated this item.
 

Restrict Object Allocation to Specific Memory Types

While C++'s three memory storage types provide an unparalleled degree of flexibility with respect to memory management, this diversity can sometimes make things more difficult—like when you need to allocate objects of a certain class exclusively on the free-store. Find out how to enforce memory allocation policies by controlling the access type of a class's member functions. 


advertisement
C++ inherited from C its three memory storage types: automatic storage (also called stack memory), static storage for namespace-scope objects and local static objects, and the free-store (also called the heap), which is used for dynamically-allocated objects.

In many cases, this diversity complicates things. For example, in mobile platforms such as Symbian, free-store objects are mandatory due to the system's tiny stack size. Likewise, garbage collectors and smart-pointers require that objects be allocated on the free-store exclusively. But in other cases, you want to ensure that objects are never allocated on the free-store. The following sections show how to enforce such class-specific memory usage policies.


How do you ensure that objects of a certain class are allocated on the free-store exclusively? Similarly, how can you encourage automatic and static storage types for a given class while disabling free-store allocation?


Enforce memory allocation policies by controlling the access type of a class's member functions.

  Next Page: Disabling Static and Automatic Objects
Page 1: IntroductionPage 3: Disabling Allocation on the Free-store
Page 2: Disabling Static and Automatic Objects 
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