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 Daniel G · Jul 25, 2013 at 03:53 PM · iphoneperformancelogicpublic strings

Do "Dynamic Public Strings" effect iPhone Performance?

Hello, I would like to know if public strings, that are getting updated every time a user taps on object, (Once every two seconds MAX) will effect the performance of the game on iOS? Should i make these strings private? Or does it not matter?

Thanks Daniel

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
Best Answer

Answer by Jamora · Jul 25, 2013 at 04:01 PM

It matters in the sense that each string that is changed creates garbage (the old string), which Unity must then, at some point clean up. This is called Garbage Collection, and every time it is done it takes a lot of CPU time, so the user might notice lag.

You should consider using the System.StringBuilder class for strings that are frequently changed, because it does not create garbage.

Comment
Add comment · Show 8 · 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 Daniel G · Jul 25, 2013 at 04:04 PM 0
Share

@Jamora Excellent, Do old strings get gotten rid of at scene change or only at application quit? Because the user might tap less than 30 times over the course of my 3D menu scene lol!

avatar image Daniel G · Jul 25, 2013 at 04:06 PM 0
Share

Is there a way to clean it up after every change? That seems like it would be useful for me because the user doesn't even tap that often throughout the menu or would this lag? If it would lag how bout at the loading screen? Whilst loading a level?

avatar image Daniel G · Jul 25, 2013 at 04:08 PM 0
Share

Also one last thing, Is there a difference between public and private strings? In performance respects? Or is it just dealing with old strings?

avatar image Daniel G · Jul 25, 2013 at 04:41 PM 0
Share

Sorry Unity was down for a $$anonymous$$ute! So Do you have any thoughts on the comments above? Thanks

avatar image Jamora · Jul 25, 2013 at 05:00 PM 1
Share

Thoughts keep co$$anonymous$$g at me too... but I use the edit button =)

  • No performance difference between public and private strings. As they're just visibity modifiers.

  • Garbage gets collected when the memory heap is almost full, you can read more about this in the GC link in my answer and following up at memorymanagement.org

  • You can not force Unity to make a GC, but you can tell Unity at an appropriate time to see if there is need for one by using System.GC()

Show more comments

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

Unity Screen.SetResolution gives me black screen on iPhone 4S 1 Answer

Performance of C# Events on iPhone/Android 1 Answer

Performance lag every 1 second on iphone 4s 2 Answers

Using Conditional Compilers? 1 Answer

performance query 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