Unity Tip: Use TryGetComponent instead of GetComponent to avoid memory allocation in the Editor
If you are a Unity developer, you may find that memory allocation in the editor when you call GetComponent() to query for a component that doesn’t exist. Just like the screenshot below.

It should be noted that this memory allocation will only occur in the Editor. But why is this memory allocation…