GithubHelp home page GithubHelp logo

isabella232 / zombieobjectdetector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unity-technologies/zombieobjectdetector

0.0 0.0 0.0 95 KB

Tool for detecting "Fake Null" C# instances.

License: Other

C# 100.00%

zombieobjectdetector's Introduction

Zombie Object Detector

Scripts to detect and diagnose zombie objects.

Description of Zombie Objects

The best description of what we mean by a "zombie" object is in a 2014 blog post here https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/. Specifically the paragraph labelled "purpose two".

To recap: Many C# classes in the UnityEngine namespace act as wrappers to instances of corresponding C++ classes, which hold the actual data. The class UnityEngine.GameObject is an example. Zombie objects are instances of these C# classes that have outlived their C++ counterpart. The C++ instances are destroyed in an entirely deterministic fashion, for example on scene transition. On the other hand the C# instances are garbage collected just like any other C# object. This means that there is an opportunity for the C# object to remain in existence by being referenced by other objects, static variables, etc.

How this tool determines Zombie Objects

The tool attempts to traverse every instance of every class. From any one object, it uses reflection to obtain every field of that object, and simply recurses into each one. It does this until it has examined every object in memory.

An object is considered a zombie if it satisfies all of the following criteria:

  • It is not actually null.
  • It is a subclass of UnityEngine.Object.
  • When you compare it to null using (obj as UnityEngine.Object) == null, it returns true.

Installation

  • Install the package using the Unity Package Manager window, using Add Package from Git URL.

This repository contains an example project that contains various examples of Zombie objects. These examples are simple and easy to fix. In larger projects this is not always the case. This tool will help you find them, and give you a trace of where and what is keeping them alive.

Credits

The project was started by Stewart McCready (@StewMcc) during his internship at Unity, with subsequent work by Peter Pimley (@peter-pimley-unity).

zombieobjectdetector's People

Contributors

peter-pimley-unity avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.