Circular ref loop and exceed memory

Hej !

I’m sorry maybe it’s a stupid question but does anyone know how to solve that please ? Try Haxe !
The only way I found is to use kind of “Lazy” like that : Try Haxe !

Thanks for your answers

You’ll have to make sure that one of the tpl == null checks doesn’t hold upon recursion. For instance, something like this should do the trick:

	public function getTpl():TBTpl {
		if (tpl == null) {
			tpl = {
				a: null
			}
			tpl.a = a.getTpl();
		}
		return tpl;
	}
1 Like

Waw, of course you’re right, I just didn’t noticed that it can never be initialized because it loops before it finished…
Thanks very much.