Function ecs_delete_empty_tables


#include <include/flecs.h>

FLECS_API int32_t ecs_delete_empty_tables(ecs_world_t *world, ecs_id_t id, uint16_t clear_generation, uint16_t delete_generation, int32_t min_id_count, double time_budget_seconds)


Cleanup empty tables. This operation cleans up empty tables that meet certain conditions. Having large amounts of empty tables does not negatively impact performance of the ECS, but can take up considerable amounts of memory, especially in applications with many components, and many components per entity.

The generation specifies the minimum number of times this operation has to be called before an empty table is cleaned up. If a table becomes non empty, the generation is reset.

The operation allows for both a "clear" generation and a "delete" generation. When the clear generation is reached, the table's resources are freed (like component arrays) but the table itself is not deleted. When the delete generation is reached, the empty table is deleted.

By specifying a non-zero id the cleanup logic can be limited to tables with a specific (component) id. The operation will only increase the generation count of matching tables.

The min_id_count specifies a lower bound for the number of components a table should have. Often the more components a table has, the more specific it is and therefore less likely to be reused.

The time budget specifies how long the operation should take at most.


world - The world.

id - Optional component filter for the tables to evaluate.

clear_generation - Free table data when generation > clear_generation.

delete_generation - Delete table when generation > delete_generation.

min_id_count - Minimum number of component ids the table should have.

time_budget_seconds - Amount of time operation is allowed to spend.

Number of deleted tables.


Line 1510 in include/flecs.h.