Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6611109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:55:41+00:00 2026-05-25T19:55:41+00:00

Currently, I have all my objects managing their own memory, allocating with new in

  • 0

Currently, I have all my objects managing their own memory, allocating with new in their constructors typically, and using delete in their destructors. This works for now, but the number of classes I have that use arbitrary amounts of memory is growing. The fact that new is essentially a “request” also bothers me, since these objects have no code within them to handle being told “no”, and I don’t want to rely on Exception Handling if I do not need to.

  • Is it beneficial in terms of performance to completely
    shield all calls that allocate memory, to a single class that handles
    every memory allocation on the heap, probably allocating large chunks
    at a time and using placement new to deal out references?

  • Is the use of memory allocation in smaller classes a big enough concern to even bother with this?

  • Can I still use STL containers and force them to use the heap I
    provide?

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:55:42+00:00Added an answer on May 25, 2026 at 7:55 pm

    Can I still use STL containers and force them to use the heap I provide?

    STL containers accept custom allocators:

    http://en.wikipedia.org/wiki/Allocator_(C%2B%2B)#Custom_allocators

    Here is a thread with links to samples:

    Compelling examples of custom C++ allocators?

    Is it beneficial in terms of performance … ?

    You can only find out by writing your application, coming up with a set of reproducible test scenarios, and running your code in a profiler. If you find the memory allocation to be a significant portion of the running time, then you might benefit from a better allocation strategy.

    If you can break up your program to a feature level, and can come up with realistic scenarios for each case, you don’t have to have your whole program working to do this. But remember that time spent optimizing is time that could be spent testing or coding new features 🙂 Do what is necessary and no more…

    Is the use of memory allocation in smaller classes a big enough concern to even bother with this?

    Depending on your program, how sensitive you are to big allocation hitches, how often you allocate in loops, etc, it is possible. Profile 🙂

    While developing your app, you can still be sensitive to allocations – create automatic storage (stack local) variables when you can, and allocate dynamically only when you must.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a source control folder in TFS with all of my source
I currently have a bunch of repositories like so IMyRepository IAnotherRepository They all inherit
I currently have a issue with firefox, where all other browser behave in the
I currently have an iPhone application with a tabbar and multiple viewcontrollers. All the
All, I currently have two projects that are under SourceSafe that I am unable
All, I currently have my solution comprising of 2 Class librarys and a Web
Backgroup: We are looking at SAS BI Dashboard. We have currently implemented almost all
I have an sql statement that currently is just returning all the end parent
I am currently building a site and all the books I have read on
I currently have a log object I'd like to remove objects from, based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.