[Tip] Use '[HideInEditor]' Attribute more actively!

TL:DR - Use [HideInEditor] more often if you have a chunk of memory as public member, even it is not that big!

I met strange hang of editor recently when selecting certain Actor while testing the application.
Editor did not respond any user interaction, and the FlaxEditor.exe held 100% of a core. Strangely, Its memory consumption rose up constantly with the time even while not answering my input.
I forcefully terminated FlaxEditor.exe after watching it allocs over 60GBytes of system memory with still nothing changes.
It only happened when I select that certain Actor, and game itself was running all okay if I do not select it in the engine editor. That made me to notice the problem late.

At first I thought it was typical human error of me, so I tried to isolate the problem.
After a few minutes I found that a call of an allocation of memory over the subscene actors makes that mysterious phenomenon.
It was not problematic as itself in a matter of code, so I attempted to make a reproducable minimal example. I tested a few cases, and found out what made the hang.

I allocated a public field a little large - about over a megabyte in heap - in the script inside that actor. It was undoubtably my bad😥 because it was public - which is evil! But a few words for my defence, it was temporary to make it accessed remotely by other subscene’s other actor, and was in middle of test and construction - proper factory methods are not yet made.

I don’t know how realtime synchronication of script members rolls and how much memory is needed to properly reflect the properties/fields, but didn’t expect only a few megabytes of single field made my editor fall into some serious pitfall and allocate multiple thousands times of more memory!

I immediately added the [HideInEditor] attribute to the field and the hang was gone.

And I promise I will change that shady public properties after the test is finished! :sweat_smile: