Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by XienDev · Mar 21, 2013 at 05:50 PM · guicontentmemory leaks

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"));
     }


Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image deltamish · Mar 22, 2013 at 06:00 AM 1
Share

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

avatar image XienDev · Mar 22, 2013 at 07:18 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Eric5h5 · Mar 22, 2013 at 07:03 AM

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

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Mar 22, 2013 at 07:10 AM 2
Share

E, would you say it's better to just edit-awat such incorrect ter$$anonymous$$ology?

Or is it more instructive if the incorrect ter$$anonymous$$ology remains on the board, with a note such as you have added?

avatar image Seth-Bergman · Mar 22, 2013 at 07:14 AM 1
Share

try to err on the side of caution when editing ter$$anonymous$$ology.. without the misleading context, Eric's answer would fail to enlighten the rest of us!

@Eric5h5 you make this seem too simple :/

avatar image Eric5h5 · Mar 22, 2013 at 07:31 AM 2
Share

It is pretty simple really. :) I've sometimes seen a tendency for people to say "memory leak" when they're just referring to memory allocation. Allocating memory is fine, as long as it's released when no longer used (and since Unity is a managed environment, I'm not sure it's even possible to cause a memory leak with scripts, unless you're triggering a bug in Unity itself).

Of course, repeatedly allocating too much memory can lead to the garbage collector running frequently, which you'd generally want to avoid. So you'd try not to do allocations unnecessarily, but even if you do, it's not a serious problem like a memory leak. Deallocating memory on the stack is really cheap, though, since it's just moving the stack pointer and doesn't involve garbage collection.

avatar image XienDev · Mar 22, 2013 at 07:39 AM 0
Share

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)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Car enter and exit script not working 1 Answer

health problem 1 Answer

Disable GameObject Only Father Not Children 2 Answers

Weird problem with gunscript 2 Answers

Flight mechanics 2D, variables vs forces 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges