Sorry, I corrected the code and now there is no error. Since I'm working with many Arrays, PoolVector2Array and a while loop, it seems that the arrays were growing always (or I suppose that). Moreover, I found better algorithm already implemented in Godot. Thanks for comment