• 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 /
  • Help Room /
avatar image
0
Question by Suk9 · Feb 08, 2016 at 01:11 AM · memory leak

Mono memory increases when switching scenes

In unity 5.3.0 f4 I created a test project with two empty scenes with a button that allows me to switch scenes. After building it in a standalone player as I switch between scenes constantly I noticed in the profiler memory used total, the mono memory increments slowly (probably 50kb after 4 scene switch). Am I doing something wrong or misinterpreting the profiler? This is crucial because I have a project that involves switching scenes many times and concerned about the mono memory going up. Thanks

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Wrymnn · Feb 08, 2016 at 09:09 AM

Hey, you can try to use:

  • http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.UnloadScene.html Although all objects from previous scenes should be destroyed automatically, unless marked as DOntDestroyOnLoad()

  • You can also try cleaning memory manually by calling GC.Collect(), see if it helps.

Maybe some amount of memory garbage is still produced by Unity when switching scenes?

Comment
Add comment · Show 3 · 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 Suk9 · Feb 09, 2016 at 03:32 AM 0
Share

Thanks for the reply. tried using unloadscene, and call GC.Collect() in the start method but the mono memory still increases. I believe the GC.Collect() might have no effect since mono is unity native code. I kept switching scenes until the mono memory went up to 1mb and I stopped doing anything to see if if the memory eventually goes down but it just stays there

avatar image Wrymnn Suk9 · Feb 09, 2016 at 07:15 AM 0
Share

I found an answer here: http://answers.unity3d.com/questions/181543/real-memory-isnt-freed-when-changing-scene-on-ios.html

Basically, mono`s GC does clear up memory, but doesn`t defragment it, so it is not returned to OS. You cannot do anything about it, as from what I have read.

avatar image Suk9 Wrymnn · Feb 11, 2016 at 02:40 AM 0
Share

Oh okay thanks for the link. I'll probably bug report and see if they can do anything about that upon the next release.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

41 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Profiling differences between Unity and Xcode Instrumnents on our project -1 Answers

GfxDriver memory issue on PC [SOLVED] 1 Answer

Massive memory leak in "Not Saved" (Unity 2017.1) 9 Answers

Memory leak when HttpWebRequest ssl handshake failed. 0 Answers

How to properly display debug messages on UI 0 Answers


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