源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

121 行
3.1 KiB

  1. //the idea is to only expose the very very lowest level data in the unity api. this data is uncrawled.
  2. //you get the raw heap bytes, you get typedescriptions, and an overview of native objects, and that's it.
  3. //
  4. //the crawler, the higher level "c# idiomy api", and the UI window that uses that api
  5. //we can develop in an opensource github project, and iterate
  6. //on outside of the unity release trains.
  7. /*
  8. using System;
  9. namespace UnityEditor.Profiler.Memory
  10. {
  11. [Serializable] //note: this snapshot is completely serializable by unity's serializer.
  12. public class PackedMemorySnapshot
  13. {
  14. public PackedNativeUnityEngineObject[] nativeObjects;
  15. public PackedGCHandle[] gcHandles;
  16. public Connection[] connections;
  17. public ManagedHeap managedHeap;
  18. public TypeDescription[] typeDescriptions;
  19. public string[] classIDNames;
  20. }
  21. [Serializable]
  22. public struct PackedNativeUnityEngineObject
  23. {
  24. public string name;
  25. public int instanceID;
  26. public int size;
  27. public int classID;
  28. }
  29. [Serializable]
  30. public struct PackedGCHandle
  31. {
  32. public UInt64 target;
  33. }
  34. [Serializable]
  35. public struct Connection
  36. {
  37. //these indices index into an imaginary array that is the concatenation of snapshot.nativeObject + snapshot.gcHandles snapshot.
  38. public int from;
  39. public int to;
  40. }
  41. [Serializable]
  42. public class ManagedHeap
  43. {
  44. public HeapSegment[] segments;
  45. public VirtualMachineInformation virtualMachineInformation;
  46. }
  47. [Serializable]
  48. public class HeapSegment
  49. {
  50. public byte[] bytes;
  51. public UInt64 startAddress;
  52. }
  53. [Serializable]
  54. public struct VirtualMachineInformation
  55. {
  56. public int pointerSize;
  57. public int objectHeaderSize;
  58. public int arrayHeaderSize;
  59. public int arrayBoundsOffsetInHeader;
  60. public int arraySizeOffsetInHeader;
  61. public int allocationGranularity;
  62. };
  63. [Serializable]
  64. public class TypeDescription
  65. {
  66. public string name;
  67. public string fullname;
  68. public int @namespace;
  69. public int assembly;
  70. public FieldDescription[] fields;
  71. public byte[] staticFieldBytes;
  72. public int baseOrElementTypeIndex;
  73. public int size;
  74. public UInt64 typeInfoAddress;
  75. public int typeIndex;
  76. public bool IsValueType
  77. {
  78. get { return (flags & TypeFlags.kValueType) != 0; }
  79. }
  80. public bool IsArray
  81. {
  82. get { return (flags & TypeFlags.kArray) != 0; }
  83. }
  84. public int ArrayRank
  85. {
  86. get { return (int) (flags & TypeFlags.kArrayRankMask) >> 16; }
  87. }
  88. private TypeFlags flags;
  89. private enum TypeFlags
  90. {
  91. kNone = 0,
  92. kValueType = 1 << 0,
  93. kArray = 1 << 1,
  94. kArrayRankMask = unchecked((int) 0xFFFF0000)
  95. };
  96. }
  97. [Serializable]
  98. public class FieldDescription
  99. {
  100. public string name;
  101. public int offset;
  102. public int typeIndex;
  103. public bool isStatic;
  104. }
  105. }*/