4 ms·
It is not a solution for all cases.
by pebal 4y ago
It is not a solution for all cases.
- wiseowise 4y agoCare to give cases where it is not a solution?
- pebal 4y ago- Some graph structures. The shared_ptr does not release circular data structures and has a lot of memory overhead. - Memory managing of concurrent containers. Lock-free algorithms requires GC or the hazard pointers and these are basically based on GC. - You often need the GC engine when you implementing or integrating another language.
- hgs3 4y agoRAII amounts to reference counting which means you need to handle circular references yourself. A garbage collector should handle them automatically. In addition to memory, GC's can catch other unused resources like unclosed file handles.
- fasterik 4y agoArena allocation is useful when many objects have the same known lifetime. An example from games is per-frame allocations. All objects needed only for the frame being rendered are carved out of a large chunk of preallocated memory. The chunk is reused every frame instead of being freed back to the system allocator. In addition to the performance benefits, this results in less memory fragmentation.