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

  • Home
  • SEARCH
  • 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 7488957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:07:05+00:00 2026-05-29T15:07:05+00:00

As it seems, placement new creates a new object on a preallocated memory, so

  • 0

As it seems, placement new creates a new object on a preallocated memory, so does it mean that it would take less time? Looks like it’s faster then allocating using the old ordinary new. Then, if this is so convenient and faster, why not use placement new all the time?

  • 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-29T15:07:07+00:00Added an answer on May 29, 2026 at 3:07 pm

    the normal (nonplacement) new is basically equivalent to doing

    T* ptr = static_cast<T*>(malloc(sizeof(T)));
    new(ptr) T;
    

    Of course the reality looks a bit different due to errorchecking and such, but the result is more or less the same (through not identical, you can’t delete a pointer allocated that way, instead you need to call the destructor explicitely (ptr->~T()) and then release the memory using free).

    So placement new should indeed be faster then non placement new, since it doesn’t need to allocate the memory. However the problem is that the memory needs to be allocated somewhere. So you have essentially replaced one call to new with a call to placement new and some code for the allocation somewhere (if not why would you use new in the first place?). It should be obvious that this is less convinient and more bug prone.

    Now of course you can write a faster allocation method, but for that you typically need to do some sort of tradeoff. It’s not going to be easy to write a allocator which is faster without either using more memory (extra data for faster identification of free blocks) or making it very specific (writing fast allocation of a single objectsize is much easier then a general one). In the end it is typically not worth the effort (for scenarious where it is worth the effort it has likely already been done, so you could use an existing allocator (which likely uses placement new internally)).

    There are of course uses for placement new (sometimes you do have the memory preallocated), but that is simply not the common case

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

Sidebar

Related Questions

I was just wondering how placement new would behave when it is passed a
It seems that Django doesn't have a convention on the placement of template files.
Seems that requirements on safety do not seem to like systems that use AI
Is it possible to actually make use of placement new in portable code when
I'm trying to detect memory leaks by globally overloading new and delete for debug
Seems to me most of developers completely ignore this features. People prefer handling security
Seems like a simple enough question but I can't seem to find the answer.
Seems like a simple problem: I have an SVN repo inside our firewall. I
Seems so basic, I can't believe I don't know this! I just need a
Seems like the subtraction is triggering some kind of issue and the resulting value

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.