Problem with Circular References

Started by
2 comments, last by Marcus L 9 years, 10 months ago

Hi again smile.png

So, I've stumbled across a strange issue with circular references. It seems AngelScript doesn't like it when I feed a member variable a reference to its owner (not too surprising, all things considered).

Here is an example of what I mean: (I'm using the "any object"-addon in this example)


class A
{
	any test;
	A()
	{
		test.store(@this);
	}
}

void main()
{
	A a();
}

After running this code, I get the following error messages as I exit my application:


ERR:  (0, 0) : ERR : Object {4}. GC cannot destroy an object of type 'A' as it doesn't know how many references to there are.
ERR:  (0, 0) : ERR : Object {5}. GC cannot destroy an object of type 'any' as it can't see all references. Current ref count is 1.
ERR:  (0, 0) : ERR : Object {76}. GC cannot destroy an object of type '_builtin_objecttype_' as it can't see all references. Current ref count is 2.
INFO:  (0, 0) : INFO : The builtin type in previous message is named 'A'

While this doesn't actually cause any memory leaks as far as I can tell, I still suspect this might lead to problems. I have tried to call scriptEngine->GarbageCollect(asGC_FULL_CYCLE) before scirptEngine->Release(), same result. So now I'm wondering what might be causing this. Is this expected behavior perhaps?

(I'm using AngelScript 2.29.0 btw)

Advertisement

Never mind. Seems it was a mistake on my part (had modified the EnumReferences callback sleep.png ).
Mods may delete this thread if they wish (the manual answered all my remaining questions).

Ah, thanks for confirming that it was not a bug. smile.png

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

No problem smile.png . Sorry if I caused you any headaches!

This topic is closed to new replies.

Advertisement