Placement New in C + +

Source: Internet
Author: User

Placement New in C + + is: The overloaded version of operator new, which is used to create objects on already allocated memory. This allows the memory to be manipulated in user space, reducing the cost of object generation, controlling the object's address to reduce memory fragmentation, and object pool estimation.

classa{ Public: A () {cout<<"A"<<Endl; }    ~A () {cout<<"~a"<<Endl; }};intMain () {void* T=MALLOC (sizeof(Char)* -); A* a=New(t) A (); Delete A;}

Function prototype: void *operator new (size_t, void *p) throw () {return p;}

The above is called after: Oerator new (sizeof (a), a).

Recently see Netty source, buffer unexpectedly use jemalloc things, it seems to take some time to chew down this piece

Placement New in C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.