Is there a way to use queue_free without locking the thread?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

So I was reading the background loading page doc listed here:

I’ve been using the resource_queue.gd class, and it’s been working amazing. All the new levels load in smoothly and there are no hiccup or “game freezes” when switching to a new level.

However… some levels (which were loaded in, that were fairly large), when using queue_free() on them, they will actually cause the game to freeze for 100-500ms or so.

So that makes me wonder… is it possible to run queue_free() on an node in the background so the hiccup or " thread locking " doesn’t happen?

Thanks in advance!

What happens if you hide them first and then queue them?

rredesigns | 2017-05-09 04:53

Never made something so big that affects performance while removing, can you try removing it from the tree first?

Also check the profiler, may give a hint of where the bottleneck is (maybe many nodes processing that delay the deletion?).

eons | 2017-05-09 09:04

Removing from tree would be great indeed, especially if you do it in another thread.
Another solution, which might look dirty, would be… not free it, and keep it for later^^

Zylann | 2017-05-10 12:58