On every script reload, this strange entry appears in the profiler, creating a huge amount of garbage which slows down iteration times significantly.
What is this? How can I get rid of it?
Using Unity Version 2020.1.17f1
Edit: We don’t have any MissingComponents in our Scenes, I made a script to check and remove them, using RemoveMonoBehavioursWithMissingScript().
(next line is also very strange - calling GC.Alloc 1.699.287 times on script reload? All in all Script Reloading takes 32 seconds, every single time - I want to fix this, somehow)
Without further details, like e.g. some callstacks for these allocations I’m not sure I can give you any answer to this. I’m not even sure if I would share your assessment that the extra calls (I’m assuming you mean GC.Allocs caused by the GetComponentNullErrorWrapper calls that are marked as EditorOnly?) have no use for you, though I can appreciate that it might seem like that without you getting direct error logs in the console.
That’s a freaking pain in the ass, I want my game to run smoothly within the Editor…I don’t even have an option to disable those “Editor” invisible messages (they’re not even showing in the Editor Log window)
Thanks, yes that’s what i did in a custom method before your answer, but the problem is that i have to refactor all my xxx.GetComponent() code if i don’t have a solution from Unity. It’s not blocking but it uses logs for nothing (And I already handle the nulls in the code so i don’t have to get these extra Logs of the Editor when no nullPointerException occurs at all in the code)
GetComponent in the Editor when there is no component doesn’t log an error message. It creates a string with the info to log when trying to access it, as by that point the relevant content that’s only present on the call stack that tried to get it is gone.
You can swap your GetComponent and nullchecks for TryGetComponent calls.
The prob the log message isnt visible when no component so it’s like magical stuff and I don’t like it. Not sure why they don’t appear tho. Thanks for the reply, I ended using TryGetComponent, i think getcomponent is definitely a bug performance issue when running in the editor, if only we had the logs present clearly in the standard console but i have no idea where unity puts them.
Its an error message that is only used when/if you trying access the fake-null object of a failed GetComponent<T> call. It’s there to provide an informative error if you do something wrong. This has been the behaviour of GetComponent<T> in the editor for many years.