public static Color32[] GetManagedMemorySectionUsageAsTextureData(PackedMemorySnapshot snapshot, PackedMemorySection memorySection)
        {
            List <PackedConnection> references = new List <PackedConnection>();

            snapshot.GetConnections(memorySection, references, null);

            var pixels = new Color32[k_TextureWidth * k_TextureHeight];

            var total        = new Rect(0, 0, k_TextureWidth, k_TextureHeight);
            var addressSpace = memorySection.size;

            for (int n = 0, nend = pixels.Length; n < nend; ++n)
            {
                pixels[n] = k_ManagedMemoryColor;
            }

            for (int n = 0; n < references.Count; ++n)
            {
                var   reference = references[n];
                ulong address   = 0;
                ulong size      = 0;
                switch (reference.toKind)
                {
                case PackedConnection.Kind.Managed:
                    size    = (ulong)snapshot.managedObjects[reference.to].size;
                    address = snapshot.managedObjects[reference.to].address;
                    break;

                default:
                    Debug.LogErrorFormat("{0} not supported yet", reference.toKind);
                    continue;
                }

                var offset = address - memorySection.startAddress;

                var left  = (int)((total.width / addressSpace) * offset);
                var width = (int)Mathf.Max(1, (total.width / addressSpace) * size);

                for (int y = 0; y < k_TextureHeight; ++y)
                {
                    for (int x = left; x < left + width; ++x)
                    {
                        var index = k_TextureWidth * y + x;
                        pixels[index] = k_ManagedObjectMemoryColor;
                    }
                }
            }

            return(pixels);
        }
Exemplo n.º 2
0
            public override void ThreadFunc()
            {
                var references   = new List <PackedConnection>();
                var referencedBy = new List <PackedConnection>();

                if (objectProxy != null && objectProxy.gcHandle.isValid)
                {
                    snapshot.GetConnections(objectProxy.gcHandle.packed, references, referencedBy);
                }

                if (objectProxy != null && objectProxy.managed.isValid)
                {
                    snapshot.GetConnections(objectProxy.managed.packed, references, referencedBy);
                }

                if (objectProxy != null && objectProxy.native.isValid)
                {
                    snapshot.GetConnections(objectProxy.native.packed, references, referencedBy);
                }

                if (objectProxy != null && objectProxy.staticField.isValid)
                {
                    snapshot.GetConnections(objectProxy.staticField.packed, references, referencedBy);
                }

                if (memorySection.HasValue)
                {
                    snapshot.GetConnections(memorySection.Value, references, referencedBy);
                }

                if (staticFields != null)
                {
                    foreach (var item in staticFields)
                    {
                        snapshot.GetConnections(item, references, referencedBy);
                    }
                }

                referencesTree   = referencesControl.BuildTree(snapshot, references.ToArray(), false, true);
                referencedByTree = referencedByControl.BuildTree(snapshot, referencedBy.ToArray(), true, false);
            }