Is using new GUIContent() in Unity causes memory leaks?

If I do not make GC.collect(), Is using new GUIContent() in Unity causes memory leaks like creating new classes? I’m interested in this question cose of found this thing in unitydoc, I heard about automatic memory managment, but does not this code will increase the frequency of them?:

    void OnGUI() {
        GUI.Button(new Rect(0, 0, 100, 20), "Click Me");
        GUI.Button(new Rect(0, 30, 100, 20), new GUIContent("Click Me"));
    }

Hi I dont think so did you try using profilier if donot have pro just go to stats and ths PFs before and after using GUI Contnet

I have got a unity free, and there is not profiler, but thanks for the idea

1 Answer

1

No, structs are allocated on the stack. Also, please don’t misuse the term “memory leak”. That refers to memory which is never reclaimed.

E, would you say it's better to just edit-awat such incorrect terminology? Or is it more instructive if the incorrect terminology remains on the board, with a note such as you have added?

try to err on the side of caution when editing terminology.. without the misleading context, Eric's answer would fail to enlighten the rest of us! @Eric5h5 you make this seem too simple :/

Can you modify your answer and move your coment into it, your coment gives more info then the answer ? =) btw Before I've started using unity I'd never used managed environment (mono/.Net/Java)