• 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
1
Question by vexe · Feb 26, 2014 at 02:37 PM · sceneobjectsresourcesfindobjectsoftypeall

Empty Project & Scene, showing up tons of loaded stuff in Unity 4.3.3f1 and not in 4.3.1f1?

So, one of my scenes were a bit suspicious to me, it's kind of slow (compile-wise for example) not like the other scenes, so I went ahead and printed out whatever that's loaded in memory via Resources.FindObjectsOfTypeAll - I found very amazing results, there were tons of stuff! related and unrelated (around 1900 objects).

Then I created a new project, with an empty scene, and ran a test:

 [MenuItem("Test/Leak")]
 public static void s()
 {
     var logFile = @"C:\Users\vexe\Desktop\TEST LOG.log";
     if (!File.Exists(logFile)) File.Create(logFile).Close();

     UnityEngine.Object[] objList = Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Object));
     using (var writer = new StreamWriter(File.Open(logFile, FileMode.Open))) {
         foreach (Object obj in objList) {
             Debug.Log("Name: " + obj.name + " Type: " + obj.GetType());
             var s = "Name: " + obj.name + " Type: " + obj.GetType();
             writer.WriteLine(s);
         }
     }
 }

I got 1620 objects! ranging from textures, materials, shaders, etc etc.

A sample log is seen here (Running in Unity 4.3.3f1)

I got the same results with GameObject.FindObjectsOfTypeAll, and Object.FindObjectsOfTypeAll

In Unity 4.3.1f1, Object.FindObjectsOfTypeAll printed only around 8 objects, no more!

What's going on here? what are these 'objects'? is this something I should be concerned about? - I was hoping to use this method to debug my scene, but obviously with that amount of output, I can't really make something useful out of it, this makes debugging scenes a lot harder, since I won't know what's relevant from what's not...

I then tried Resources.UnloadUnusedAssets, and EditorGUI.UnloadUnusedAssets they didn't do that much, in the case of the empty project, I got 4 less objects...

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

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

Best practices about shared objects 0 Answers

Move Objects in beginning of scene 1 Answer

Objects glitch between each other and the terrain 2 Answers

all objects are abruptly disappeared 2 Answers

Finding objects on scene 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