5 ms·
Because in C, every allocation incurs a responsibility to track its lifetime and to know who will eventually free it. Copying and moving buffers is also prone t
by bluetomcat 11mo ago
Because in C, every allocation incurs a responsibility to track its lifetime and to know who will eventually free it. Copying and moving buffers is also prone to overflows, off-by-one errors, etc. The generic memory allocator is a smart but unpredictable complex beast that lives in your address space and can mess your CPU cache, can introduce undesired memory fragmentation, etc.
In Java, you don't care because the GC cleans after you and you don't usually care about millisecond-grade performance.
- jstimpfle 11mo agoNo. Look up Arenas. In general group allocations to avoid making a mess.
- jenadine 11mo agoI don't see how arenas solve the problems.
- jstimpfle 11mo agoYou group things from the same context together, so you can free everything in a single call.
- rictic 11mo agoIf you send a task off to a work queue in another thread, and then do some local processing on it, you can't usually use a single Arena, unless the work queue itself is short lived.
- estimator7292 11mo agoNo. Arenas are not a general case solution. Look it up