Remix.run Logo
nly 2 days ago

Efficient memory allocation is part of a well written designed API.

Languages like C++ give you a tonne of options here, from passing in scratch buffers to libraries, passing in reusable containers, move semantics, to type erased primitives like std::memory_resource and std::shared_ptr

tialaramex 2 days ago | parent [-]

Perhaps rather than "a tonne of options" people might like to have fewer that are actually good ?

nly 2 days ago | parent [-]

I'd you're using an unmanaged language then you need to think about memory allocation and ownership.

This is something you should think about early on in your design.

tialaramex 2 days ago | parent [-]

I do think about such things, but having "a tonne of options" when they're mostly terrible is the opposite of helpful.

Let's pull out an easy one, you mention the move assignment semantic. In C++ that's a performance leak because it isn't the destructive move - so each such move incurs a creation whether you wanted one or not and it may also incur a "moved-from" check in the destructor, another overhead you wouldn't pay with the destructive move.