Jump to content
  • Advertisement
Sign in to follow this  

The use of operator "new" ?

This topic is 4314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

No, it's not quite the same. It is the so-called placement new. Basically you provide the new operator with an already allocated memory block and tell it to call an objects constructor at that position.

That's useful for object pools. The container allocates the memory for 100 objects in advance (in one single block) without ever constructing an object. Now when you request a new object the container simply calls the placement new which constructs an object at a specific position.

Note that objects constructed this way may not be deleted by calling delete. They have to specifically be only destructed:


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!