Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 mhhk88 · Jan 13, 2017 at 02:06 AM · memorycpu

inactive object or unseen object

I think you may choose either making object inactive or moving object out of screen when you hide objects. I dont want to use Instantiate and Destroy for frequent-used objects like bullets. I heard inactive objects still reside in memory, so I wonder which one takes more cpu usage or memory. Can anyone answer this ? 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
1

Answer by Hanoble · Jan 13, 2017 at 02:27 AM

When you are talking about memory optimizations at the level of removing a gameobject, such as a bullet, you are almost certainly making a premature optimization or focusing on the wrong optimization.

It sounds like you are talking about pooling objects, which is a widely used concept on mobile to help maintain FPS by not constantly doing slow Instantiate calls and simply reusing common objects (such as bullets). The idea is to shoot a bullet, once it is done (hit something or timed out) you put it into an inactive state, disable it, and then put it back into the available pool. Most pools will have an instantiate similar to that of Unity, but instead of actually making the object you simply grab the one already there, move it, initialize it, reactivate it, and let it go as if it were brand new.

Inactive objects do still reside in memory, although gameobjects are typically very small and you are unlikely to see a major benefit there. Inactive objects do not call their update functions (which could save some CPU time), but an active bullet offscreen would still consume those CPU resources (however Unity is smart enough to not render it and take up your GPU resources in most cases).

If you really want to understand the CPU and memory usage of your gameobjects, take a look at the profiler and you will find answers to your questions.

Profiler tutorial!

Comment
Add comment · Show 2 · 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 mhhk88 · Jan 13, 2017 at 02:44 AM 0
Share

Sounds like each method has its pros and cons. I may have to choose one depending on the situation. Thank you so much for your detailed and educational explanations!!!

avatar image Hanoble mhhk88 · Jan 13, 2017 at 02:57 AM 0
Share

You are welcome, if it helped you please upvote :)

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

62 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 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

CPU and memory usage between a Unity projet in Web Player and as a standalone 0 Answers

What's better? Managers using DontDestroyOnLoad or keep one in each scene? 1 Answer

Measure cpu and memory load in code? 3 Answers

How do inactive game objects affect CPU and memory? 1 Answer

Editor crash after editing in a better computer 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