My project contains many objects, also my project have many arrays that reference to these objects. Sometimes I need to delete some object, but its null anyway remains in all arrays. Check on null in every function sounds like this need to write bunches of check-on-null code. Cleaning these arrays every frame in _process() looks messy and even bad for performance. So, what should I do in this case?

You can use delta for timing the check. So it would only check the array every 0.1 seconds. This would save lots of cpu cycles.

Also, instead of using _process(), you could place the checks into a function (or functions), and call the function whenever you delete an object.

Deleting the references from the arrays might be counterproductive, though. Deleting an element in the middle of a large array is inefficient.

Your best bet is to remove the reference from the Array at the time of deletion. If it is a small number of objects, this should be fine. But because array element deletion is slow (unless for the last element) you don't want to do this every frame, or even on a timer. It should only be done exactly at the point where it is needed, meaning when the object is destroyed.

You might be able to use dictionaries instead of arrays. The lookups are about 30% slower (last time I checked), but you can get rid of hanging references with almost no overhead. I've been using dictionaries a lot lately.

So, I guess, there's no some elegant way to do this, and well, I did in every object delete() function that makes erase(self) in every array, that usually can have object in himself. Also I had an idea about creating some super_array_script.gd that connected to all arrays and some object to delete himself just should to ask the script about it and he'll delete object everywhere... but my project not so big for that overwhelming, also performance-question is hot, so I'll use aforesaid realization for now.

8 months later