|
|
|
|
|
by zarzavat
1381 days ago
|
|
> I use sanitizers to catch memory problems, but there have only been a few of those over the years. Maybe ECS just isn't that vulnerable to memory-safety problems? To expand on this a bit. In games, objects generally fit into two categories: 1. Short-lived temporary objects, usually stack-allocated or arena-allocated, etc. e.g. a point vector, or matrix. 2. Long-lived objects with indeterminate lifetime. e.g. a character or item. In the case of long-lived objects, there are various strategies you could use to make it safe e.g. using object IDs or custom smart pointers to refer to other objects that potentially might go missing instead of pointers which are bound to be corrupted. Generally you want to register all of your long-lived objects in one central location that will handle memory management. Manual, reference counting or GC are all viable strategies depending on requirements. I like Rust and would use it for games but mainly because of the package management. |
|