Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Delphi object constructors on preallocated memory

Tags:

delphi

In C++, there exists an inplace-new operator to create an object using preallocated memory. Is there an equivalent option in Delphi?

like image 222
cytrinox Avatar asked Jul 22 '26 17:07

cytrinox


1 Answers

There is no direct equivalent (that I know of), but you can achieve much the same effect (controlling how and where memory for an object type is allocated) by overriding the NewInstance class function in your custom class and providing an implementation, which provides the space for the new instance from a custom heap pool.

like image 105
500 - Internal Server Error Avatar answered Jul 24 '26 11:07

500 - Internal Server Error



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!