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 IgorAherne · Jan 04, 2014 at 11:58 PM · editorgetcomponentbackground

Unity is working on something, but on what?

Hello guys!

I am working with the Editor script and have a quite complex structure, containing different gameObjects. Before I start some tasks through a separate thread, before that - I am storing different Scripts on those gameObjects into a single list. I call this process "ScriptBaking". That includes using GetComponent for many of those objects at once 200+. It's unavoidable, since I need to store a reference to those script instances, but it's not the problem.

Keep in mind that all of this is happening in the Editor script. I display a progress bar as I am working through the bake process.

This bake process is of course not threaded. It goes well, and takes about 4 seconds to go through all the game objects, I get a nice reference to the scripts. It's okay if I do it again and again, until somewhere at 4th bake - the progress bar starts to really turtle somewhere from 70%. 5th time it will turtle at 60% and so on.

Moreover, I can see that unity is still doing something in the Mac menu. Please have a look at the picture. The progress circle makes a full turn, then starts again?

after some time (4-5 minutes after 5 re-bakes) the progress circle, or pie on the thumbnail hides after several laps. "Bake" is fine once again.

WTF is happening? :D Is it an automatic clean-up some sort? How is the progress circle tied with the turtling of "Baking"?

here is the function, gets invoked on button click from OnInspectorGUI( )

//the variables declared and initialized on the top of the editor script

 NodeCounter _nodeCounterShort = GameObject.Find("mainNodeCounter").GetComponent<NodeCounter>();
 //Node Counter contains the list of all gameObjects in the scene, "the nodes.
 
 void BakeNS(){
         
         float counter = 1; //used to display progress
 
         foreach(GameObject g in _nodeCounterShort._AllNodesInScene){
             
             NodeSpark _dump = g.GetComponent<NodeSpark>();
             _dump._NSneighbour.Clear(  );
             
             
             foreach(GameObject gg in _dump.neighbours){
                 _dump._NSneighbour.Add(gg.GetComponent<NodeSpark>());
             }
             
             EditorUtility.DisplayProgressBar("saving the NodeSparks of neighbours for every node", counter + "/" + _nodeCounterShort._AllNodesInScene.Count, counter/_nodeCounterShort._AllNodesInScene.Count);
             
             counter++;
         }
         
     }//end of BakeNS()

alt text

pie.png (280.6 kB)
Comment
Add comment · Show 1
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 IgorAherne · Jan 05, 2014 at 12:06 AM 0
Share

And by the way, all the classes are [Serializable] as well as the values in them. However, I am only setting the scripts as dirty only after the Bigger Bake, which I do later with threading.

$$anonymous$$aybe I should use something similar to HideAllFlags? I am pretty similar it's some kind of unnecessary clean up that is done after massive heap of getComponents)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HappyMoo · Jan 05, 2014 at 02:33 AM

Does anything in your Process create a lot of objects and throw them away again? It could be that after a few starts, you get memory pressure and the Garbage Collector kicks in.

Can you check your memory consumption while running your Baking?

Also, does it help if you call the Garbage Collector yourself after every run?

 GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
 GC.WaitForPendingFinalizers();

But keep in mind that the above may not be the best idea to put in production code - it's just to test if that's the problem. If it is, you would be well advised to try to improve the memory consumption issue.

Comment
Add comment · Show 1 · 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 IgorAherne · Jan 05, 2014 at 01:00 PM 0
Share

Hm, placing this at the end of the function didn't have a visible effect :< Unity pie is still displayed, and Bake is turtled :'( Problem disappears if I reimport all the assets of the project, but it's a frustrating solution ))

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

19 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

Related Questions

A node in a childnode? 1 Answer

Network - Editor + Builds = Problem with RayCasts? 0 Answers

How to check if object is skewed ? 2 Answers

Unity-target mainly for design? 1 Answer

(Editor) How to add Checkmarks to MenuItems 4 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