Delete and deleteall bug

in version 1.2.89 when I try to create 500 objects and then delete objects (on level restart for ex.), after few times I receive message:
ERROR:GAMESYS: factory.create can not create gameobject since the buffer is full.
But the same project in 1.2.87 works good.
Looks like go.deleteall doesn’t work (I checked go.delete too - same bug). =(

I’m unable to reproduce the problem. Here’s the code I’m testing with:

function init(self)
	self.objects = {}
end

function update(self, dt)
	while #self.objects > 0 do
		go.delete(table.remove(self.objects))
	end
	
	for i=1,500 do
		local id = factory.create("#factory", vmath.vector3(math.random(1,100), math.random(1,100), 0))
		table.insert(self.objects, id)
	end
end

I think you’re creating spine models whereas @britzl is creating empty gameobjects, is that correct? If that is the case, it’s an error we’ve fixed in this sprint that should be part of the 1.2.90 release.

2 Likes

yes, you right. Thanks!

And maybe you can help me with similar error message:

ERROR:GAMEOBJECT: Could not create script component, out of resources.
ERROR:GAMEOBJECT: Could not spawn an instance of prototype /gamelogic/objects/static/tree1/tree1.goc.

I can’t fing some field in project settings to change max count of scripts

There is a setting in game.project for max number of resources! :slight_smile: Check under the heading “resource” and the setting is called max_resources.

2 Likes

Thank you, very much!

2 Likes

I recheck one more time using @sven clean example with spine components. And yes, this bug about deleting spine component.
Maybe possible to add some information which of the buffers is full?

I have a question about go.delete and go.delete_all functions:
this function async, or something like this?

In my game, level restart by go.delete_all objects and then recreate it.
And in level with many objects I have next problem (by steps):

  1. create level - all ok
  2. restart level:
    2.1 go.delete_all
    2.2 create new objects - recive error:
    ERROR:GAMEOBJECT: Could not create script component, out of resources.

then I make restart one more time and all ok, then one more restart and same error (error only on every second restart). Looks like delete all have some pause before deleting (or make it async)

I tried to make pause before create new objects and it’s helped (by steps):

  1. create level - all ok
  2. restart level:
    2.1 go.delete_all
    2.2 pause before creation 0.1 sec
    2.3 create new objects - all fine

Can you explain how it’s works?

If I remember correctly (@Ragnar_Svensson, @sven, @Mathias_Westerdahl and other will tell me if I’m wrong) is that when you do go.delete() the game object will be flagged for deletion, but it will still exists for the duration of the frame and only after the frame has updated, all messages have been processed and everything has rendered will the game object actually be deleted. This means that if you delete 100 game objects and create 100 new game objects the same frame you need to be able to handle 200 game objects.

3 Likes

This explains a lot. Thank you.
Will be great to have this info in docs.

There’s a bit of documentation in the application lifecycle manual. We should probably also mention something about this in the API docs @sicher.

1 Like

I changed this from Bug to Question. If you find anything that doesn’t work as described here and documented in the manual then please let us know!

1 Like

First part of topic was a bug, but it’s already fixed in 1.2.90

Yes, now it’s just a question.
Thank you for your answer!

2 Likes