Go.delete() creates troubles because ASYNC!

We have explicitly specified limits for objects, for example 5000:

It seems that if we destroy our 5000 objects, and then create 4000, then there will be no error?
In fact, objects are destroyed asynchronously, so you can easily get into a situation where only a part of 5000 objects were destroyed, and we are already trying to create 4000 and fly out of the limit.
This situation occurs when the large game level is rebooted.

Help us! We need a method to force the destruction of objects!

If you delete 5000 objects and in the same frame create 5000 new objects you’ll need a max_instances count of 10000. The deleted objects will live until the end of the frame. Could this be what you are experiencing?

2 Likes

As Björn pointed out; when a GO is deleted in runtime, it’s “marked” for deletion so we can do all the deletes efter the frame is done in one swoop instead. For example, this means the engine doesn’t need to do reconstruct/recalculate hierarchical transforms for each delete, it will only need to do it once per frame.

4 Likes

Yes, it is async.
I already asked this question here: Delete and deleteall bug

In my case I just waiting one frame before create new objects.

I know this thread is old, but maybe we should add this to the docs? I spent a couple hours scratching my head trying to figure out why I kept getting into buffer issues assuming that go.delete was synchronous :anguished:.

@sicher https://www.defold.com/ref/go/#go.delete:-id---recursive- is API docs on github or only the manuals?

1 Like

They are in the engine source code so we can’t put them on Github unfortunately, but I’ll add a note about this.

4 Likes