+ 6

Importance of object pool and overloaded new operator

I have a couple of questions on overloaded new operator as below: 1. Does it helpful in maintaining memory pool of objects ? If yes , then what is need of placement new? If no, what is use case of overloaded new operator? 2. How can we create placement new in case of smart pointer? Is it possible at all or not? 3. In attached code , we can still use normal allocation of object (like pt3) even with available memory block from placement new. Can we block this or only end coder has to take care of not using normal new ? 4. How to use memory from memory block ? From code reference, we use pt2 as memory [4] due to int variable in struct. Do we need to keep track of what index to use from memory variable or not ? We already released pt1 before creating pt2. So can we again use memory[0] for pt2? https://code.sololearn.com/cX67t1F8upyc/?ref=app

6th Jun 2021, 1:50 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Odpowiedź