You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Thanks for making this increadible lib.
I tried to create 50M entities with prefabs but got error: fatal: allocator.c: 52: assert: size >= 0 INTERNAL_ERROR when program is finished.
To Reproduce
#include <flecs.h>
#include <iostream>
struct Position {
float x, y, z;
};
struct Velocity {
float vx, vy, vz;
};
int main(int argc, char *argv[]) {
flecs::world ecs(argc, argv);
auto person_prefab = ecs.prefab("PersonPrefab")
.set<Position>({0, 0, 0})
.set<Velocity>({0, 0, 0});
for (int i = 0; i < 50000000; i++) {
ecs.entity()
.is_a(person_prefab)
.add<Position>()
.set<Position>({static_cast<float>(i), 0, 0});
}
std::cout << "Created 50,000,000 entities" << std::endl;
return 0;
}
Your code snippet made it easy to reproduce the issue and find the problem. Thank you.
What is happening here is that on world end, a huge command queue is built to delete all those components. This queue is stored in a vector that grows as required. In the process, at some point it overflows the size parameter, which is a signed int32_t, triggering the error.
The fix has been to prevent the queue from growing to an uncontrolled size, flushing it in batches.
You're using the prefab correctly, but you can save the .add<Position>() inside the loop since the component will be already there, copied from the prefab, but would also have been added automatically by set anyway.
Describe the bug
Hi,
Thanks for making this increadible lib.
I tried to create 50M entities with prefabs but got error: fatal: allocator.c: 52: assert: size >= 0 INTERNAL_ERROR when program is finished.
To Reproduce
it gave error:
The error is after created entities but before the return line. It works fine for smaller number like 5M entities.
Btw, is this the correct way to use prefab?
Expected behavior
Should return no error
Additional context
My specs is M3 base 24GB RAM. Free RAM is around 20% when running the code.
The text was updated successfully, but these errors were encountered: