public void Initialize()
        {
            if (_treeMapView == null)
            {
                _treeMapView = new TreeMapView();
            }

            if (!_registered)
            {
                UnityEditor.MemoryProfiler.MemorySnapshot.OnSnapshotReceived += IncomingSnapshot;
                _registered = true;
            }

            if (_unpackedCrawl == null && _packedCrawled != null && _packedCrawled.valid)
            {
                Unpack();
            }

            if (_unpackedCrawl_prev == null && _packedCrewled_prev != null && _packedCrewled_prev.valid)
            {
                _unpackedCrawl_prev = CrawlDataUnpacker.Unpack(_packedCrewled_prev);
            }
        }
Beispiel #2
0
        public static CrawledMemorySnapshot Unpack(PackedCrawlerData packedCrawlerData)
        {
            var packedSnapshot = packedCrawlerData.packedMemorySnapshot;

            var result = new CrawledMemorySnapshot
            {
                nativeObjects             = packedSnapshot.nativeObjects.Select(packedNativeUnityEngineObject => UnpackNativeUnityEngineObject(packedSnapshot, packedNativeUnityEngineObject)).ToArray(),
                managedObjects            = packedCrawlerData.managedObjects.Select(pm => UnpackManagedObject(packedSnapshot, pm)).ToArray(),
                gcHandles                 = packedSnapshot.gcHandles.Select(pgc => UnpackGCHandle(packedSnapshot)).ToArray(),
                staticFields              = packedSnapshot.typeDescriptions.Where(t => t.staticFieldBytes != null & t.staticFieldBytes.Length > 0).Select(t => UnpackStaticFields(t)).ToArray(),
                typeDescriptions          = packedSnapshot.typeDescriptions,
                managedHeap               = packedSnapshot.managedHeapSections,
                nativeTypes               = packedSnapshot.nativeTypes,
                virtualMachineInformation = packedSnapshot.virtualMachineInformation
            };

            var combined = new ThingInMemory[0].Concat(result.gcHandles).Concat(result.nativeObjects).Concat(result.staticFields).Concat(result.managedObjects).ToArray();

            result.allObjects = combined;

            var referencesLists   = MakeTempLists(combined);
            var referencedByLists = MakeTempLists(combined);

            foreach (var connection in packedCrawlerData.connections)
            {
                referencesLists[connection.@from].Add(combined[connection.to]);
                referencedByLists[connection.to].Add(combined[connection.@from]);
            }

            for (var i = 0; i != combined.Length; i++)
            {
                combined[i].references   = referencesLists[i].ToArray();
                combined[i].referencedBy = referencedByLists[i].ToArray();
            }

            return(result);
        }
 public ShortestPathToRootFinder(CrawledMemorySnapshot snapshot)
 {
     _snapshot = snapshot;
 }
Beispiel #4
0
 public void Setup(MemoryProfilerWindow hostWindow, CrawledMemorySnapshot _unpackedCrawl)
 {
     Setup(hostWindow, _unpackedCrawl, null);
 }
 internal FilterItems(MemoryProfilerWindow hostWindow, CrawledMemorySnapshot unpackedCrawl, CrawledMemorySnapshot previousUnpackedCrawl)
 {
     this._unpackedCrawl         = unpackedCrawl;
     this._previousUnpackedCrawl = previousUnpackedCrawl;
     this._hostWindow            = hostWindow;
     this._currentFilter         = Filters.Everything;
 }
Beispiel #6
0
 internal void Setup(MemoryProfilerWindow hostWindow, CrawledMemorySnapshot unpackedCrawl)
 {
     this.m_unpackedCrawl = unpackedCrawl;
     this.m_hostWindow    = hostWindow;
     m_table.InvalidateData();
 }