Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.1.1] - 2024-09-10

### Added
- Added the name of the assembly to the Type details when selecting a Managed Type group.

### Fixed
- Fixed navigating with arrow keys not updating reference list in All of Memory view ([PROFB-153](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-153)).
- Fixed retention of Snapshot list expansion and scroll state so that it does not expand all items unexpectedly but remembers which sessions were collapsed and which extended ([PROFB-196](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-196)).
- Fixed dropdown text being clipped when "Allocated and Resident Memory on Device" was selected.
- Fixed an issue whereby graphics allocations not associated with a native object would display under a "No Name" category in the All of Memory table.
- Fixed issues with selecting array objects, or objects that had managed fields with arrays, when the arrays where multidimensional with one or more dimensions of size 0.
- Fixed exception when opening the Unity Objects table in Comparison mode when there are multiple MonoBehaviour or ScriptableObject types with the same name but from different assemblies.
- Fixed exception when opening the All Of Memory table in Comparison mode when either of the snapshots is from a pre 2022.2 runtime and the untracked amount is negative.
- Fixed an ArgumentOutOfRangeException when inspecting some Managed Objects ([PROFB-223](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-223)).
- Fixed longer string values not being displayed in the Managed Fields Inspector.
- Fixed an issue that caused IL2CPP VM memory to not be calculated correctly in the Summary and All Of Memory table.
- Remove deprecated UxmlFactory/UxmlTraits API usage on Unity 6.
- Add divider on "Capture" toolbar button dropdown.
- Reattributed IL2CPP VM memory from Native to Managed in the All Of Memory table.

### Changed
- Allowed Snapshots to reside in Subfolders within the configured memory snapshot path.
- Improved Snapshots folder monitoring: Changes to the folder are now reflected in the Editor without it requiring to acquire focus first.
- Improved display of managed arrays in the Selected Item Details and Managed Fields.
  • Loading branch information
Unity Technologies committed Sep 10, 2024
1 parent dade520 commit 472f2a0
Show file tree
Hide file tree
Showing 153 changed files with 7,409 additions and 546 deletions.
1 change: 1 addition & 0 deletions .signature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"timestamp":1725974903,"signature":"FUsr9InlCwm0z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2cKL2xyMnZKS1IvU2l5eEN1Q20vQWJkYnJMbXk0WjlSdm1jMGdpclA4T0lLQWxBRWZ2TzV5Z2hSKy8vd1RpTFlzUQp1SllDM0V2UE16ZGdKUzdGR2FscnFLZzlPTCsxVzROY05yNWdveVdSUUJ0cktKaWlTZEJVWmVxb0RvSUY5NHpCCndGbzJJT1JFdXFqcU51M3diMWZIM3p1dGdtalFra3IxVjJhd3hmcExLWlROQWdNQkFBRT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg"}
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,34 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.1] - 2024-09-10

### Added
- Added the name of the assembly to the Type details when selecting a Managed Type group.

### Fixed
- Fixed navigating with arrow keys not updating reference list in All of Memory view ([PROFB-153](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-153)).
- Fixed retention of Snapshot list expansion and scroll state so that it does not expand all items unexpectedly but remembers which sessions were collapsed and which extended ([PROFB-196](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-196)).
- Fixed dropdown text being clipped when "Allocated and Resident Memory on Device" was selected.
- Fixed an issue whereby graphics allocations not associated with a native object would display under a "No Name" category in the All of Memory table.
- Fixed issues with selecting array objects, or objects that had managed fields with arrays, when the arrays where multidimensional with one or more dimensions of size 0.
- Fixed exception when opening the Unity Objects table in Comparison mode when there are multiple MonoBehaviour or ScriptableObject types with the same name but from different assemblies.
- Fixed exception when opening the All Of Memory table in Comparison mode when either of the snapshots is from a pre 2022.2 runtime and the untracked amount is negative.
- Fixed an ArgumentOutOfRangeException when inspecting some Managed Objects ([PROFB-223](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-223)).
- Fixed longer string values not being displayed in the Managed Fields Inspector.
- Fixed an issue that caused IL2CPP VM memory to not be calculated correctly in the Summary and All Of Memory table.
- Remove deprecated UxmlFactory/UxmlTraits API usage on Unity 6.
- Add divider on "Capture" toolbar button dropdown.
- Reattributed IL2CPP VM memory from Native to Managed in the All Of Memory table.

### Changed
- Allowed Snapshots to reside in Subfolders within the configured memory snapshot path.
- Improved Snapshots folder monitoring: Changes to the folder are now reflected in the Editor without it requiring to acquire focus first.
- Improved display of managed arrays in the Selected Item Details and Managed Fields.

## [1.1.0] - 2023-10-16

### Changed
- Bump version to 1.1.0 from 1.1.0-pre.3.

## [1.1.0-pre.3] - 2023-09-27
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/all-memory-tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The __All Of Memory__ tab splits tracked memory into four different top-level ca

|__Category__|__Description__|
|:---|:---|
|__Managed__| Displays all Virtual Machine and Managed Heap memory allocations. The Managed Heap contains data related to __Managed Objects__ and the space that has been reserved for them. It is managed by the Scripting Garbage Collector, so that any managed objects that no longer have references chain to a root are collected. The 'reserved' amount in this category may be quickly reused if needed, or it will be returned to the system every 6th GC.Collect sweep. Check [Managed memory](https://docs.unity3d.com/Manual/performance-managed-memory.html) documentation page for more details.|
|__Managed__| Displays all Virtual Machine and Managed Heap memory allocations. The Managed Heap contains data related to __Managed Objects__ and the space that has been reserved for them. It is managed by the Scripting Garbage Collector, so that any managed objects that no longer have a references chain to a root are collected. The 'reserved' amount in this category may be quickly reused if needed and if any new allocations fit within one of the free spaces. Check [Managed memory](https://docs.unity3d.com/Manual/performance-managed-memory.html) documentation page for more details. |
|__Native__| Displays all memory that Unity allocated internally for different native objects, such Scene Objects (Game Objects and their Components), Assets and Managers, Native Allocations including Native Arrays and other Native Containers, CPU side of Graphics Asset memory, and other. This doesn't include Graphics, which is shown in a separate category. Expand this group to see the different kinds of native memory that Unity tracks.</br></br>The __Unity Objects__ subgroup displays memory that any Unity object in your application, such as a Shader or Texture2D, uses. Use this information to find areas where you could optimize memory use; you can then find these objects in the [Unity Objects tab](unity-objects-tab.md) to inspect them in more detail.</br></br>The __Unity Subsystems__ subgroup displays memory that installed modules or systems use. You can find which modules use the most memory and, if any aren't used, uninstall them to reduce how much memory your application needs.|
|__Executables & Mapped__| Displays the memory taken up by the build code of the application, including all shared libraries and assemblies, managed and native. This value is not yet reported consistently on all platforms. You can reduce this memory usage by using a higher code stripping level and by reducing your dependencies on different modules and libraries.|
|__Graphics (Estimated)__| Displays how much memory is used by the Graphics Driver and the GPU to visualize your application. The information is based on the tracking of graphics resource allocations within Unity. This includes RenderTextures, Textures, Meshes, Animations and other graphics buffers which are allocated by Unity or Scripting API. Use All Of Memory tab to explore graphics resources. Not all these objects' memory is represented in this category. For example, Read/Write enabled graphics assets need to retain a copy in CPU-accessible memory, which doubles their total memory usage. Use Unity Objects tab to explore total memory usage of Unity Objects. Also, not necessarily all memory from these type of objects resides in GPU memory. Memory Profiler is unable to get exact residence information for graphics resources.|
Expand Down
17 changes: 14 additions & 3 deletions Documentation~/filter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
apiRules:
- exclude:
hasAttribute:
uid: System.ComponentModel.EditorBrowsableAttribute
ctorArguments:
- System.ComponentModel.EditorBrowsableState.Never
- exclude:
# inherited Object methods
uidRegex: ^System\.Object\..*$
Expand Down Expand Up @@ -27,13 +32,19 @@ apiRules:
uidRegex: ^$
type: Namespace
- exclude:
uidRegex: test$
uidRegex: ^.*test$
type: Namespace
- exclude:
uidRegex: ^.*Tests$
type: Namespace
- exclude:
uidRegex: ^.*Tests\.*$
type: Namespace
- exclude:
uidRegex: Tests
uidRegex: ^.*\.Tests.*$
type: Namespace
- exclude:
uidRegex: \.Testing
uidRegex: ^.*\.Testing.*$
type: Namespace
- exclude:
uidRegex: \.Dispose$
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When you install the Memory Profiler package, Unity automatically installs the [

The memory snapshots you take with the Memory Profiler UI or the [Memory Profiler API](https://docs.unity3d.com/Documentation/ScriptReference/Profiling.Memory.Experimental.MemoryProfiler.html) contain the entire contents of the managed heap of the Player or Editor instance you are capturing.

You can see most of the data through the Memory Profiler UI, with the exception of managed allocations that do not have a garbage collection handle. These allocations might be related to Mono type data, leaked managed data, or allocations that the garbage collector has already collected and released but the memory section they were located in hasn’t been overwritten with new data. The latter happens because garbage-collected memory is not "stomped" for performance reasons.
You can see most of the data through the Memory Profiler UI, with the exception of managed allocations that do not have a garbage collection handle. These allocations might be related to Mono type data, or allocations that the garbage collector has already collected and released but the memory section they were located in has not been overwritten with new data yet. The latter happens because garbage-collected memory is not "stomped" for performance reasons.

The kind of data that you can explore in areas such as the __All Managed Objects__ view gives you an idea of what data could be included in the memory snapshot. The Memory profiler includes any object instance of a class, all fields on that object, as well as the class’ statics excluding literals such as const values.

Expand Down
2 changes: 1 addition & 1 deletion Documentation~/summary-tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following table describes the sections available in this tab:
|__Tips__| Displays any contextual warnings or additional useful information about the snapshots, such as potential issues with your snapshot and insight about how to understand an Editor capture.|
|__Memory Usage On Device__| The application footprint in physical memory. It includes all Unity and non-Unity allocations resident in memory at the time of the capture.|
|__Allocated Memory Distribution__| Displays how your allocated memory is distributed across different memory categories.|
|__Managed Heap Utilization__| Displays a breakdown of the memory that Unity manages which you can't affect, such as memory in the managed heap, memory used by a virtual machine, or any empty memory pre-allocated for similar purposes.|
|__Managed Heap Utilization__| Displays a breakdown of the memory that Unity's Scripting VM manages, which includes managed heap memory used for Managed Objects, Empty Heap Space that might've previously been used by Objects or been reserved during the last heap expansion, and memory used by a virtual machine itself. |
|__Top Unity Objects Categories__| Displays which types of Unity Objects use the most memory in the snapshot.|

Hover over any of the bars in the tab to highlight the corresponding label, and vice versa. Continue hovering your cursor over the bar or label to display how much that element contributes to the total, as a percentage.
Expand Down
39 changes: 21 additions & 18 deletions Documentation~/whats-new.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# What's new in version 1.1.0
# What's new in version 1.1.1

Summary of changes in Memory Profiler version 1.1.0 (formerly 1.1.0-pre.3).
Summary of changes in Memory Profiler version 1.1.1.

### Added
- Added the name of the assembly to the Type details when selecting a Managed Type group.

### Fixed
- Fixed an exception on capturing when the default snapshot storage path was used (./MemoryCaptures) but did not exist. It now gets created if it is missing. Custom set storage paths will still not be created as issues with these need user input to get resolved properly.
- Fixed an ArgumentOutOfRangeException in ManagedObjectInspector on selecting some object entries in the All of Memory and Unity Objects table. The field inspector UI was trying to display the managed field values of static fields that hadn't been initialized.
- Fixed Snapshot opening triggering a synchronous search via SearchService to initialize it for the Select, Find and Asset Preview functionality. As that could trigger SearchService to start indexing, this might have lead to longer stalls on opening snapshots.
- Fixed string rendering when strings included the ´\r´ character ([PROFB-113](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-113)).
- Fixed a crash on opening snapshots with very large managed memory usage ([PROFB-156](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-156)).
- Fixed messaging for resident memory breakdown data availability. Detailed resident memory breakdown data is available for snapshots taken from Unity versions 2023.1 or newer.
- Fixed the Unity Object and All Of Memory table UI so that the table mode dropdown does not disappear in a narrow window size. ([PROFB-110](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-110))
- Disabled resident memory visualization in "Unity Objects" and "All of Memory" tables for WebGL platform. WebGL doesn't provide residency status.
- Fixed bug that detailed information isn't showed for graphics resources.
- Fixed a bug when you can't switch snapshot if snapshot was previously open in compare mode.
- Fixed a managed memory leak in the Memory Profiler Module UI that the package inserts into the Profiler Window ([PROFB-160](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-160)). Also reduced the impact of a Mesh memory leak caused by UI TK ([UUM-46520](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-46520)).
- Fixed the display of the memory usage bar diagrams in the Memory Profiler Module UI that the package inserts into the Profiler Window ([PRFOB-165](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-165)).
- Fixed issue with Unity Objects view that caused some managed objects not to group and shown as separate items.
- Fixed navigating with arrow keys not updating reference list in All of Memory view ([PROFB-153](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-153)).
- Fixed retention of Snapshot list expansion and scroll state so that it does not expand all items unexpectedly but remembers which sessions were collapsed and which extended ([PROFB-196](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-196)).
- Fixed dropdown text being clipped when "Allocated and Resident Memory on Device" was selected.
- Fixed an issue whereby graphics allocations not associated with a native object would display under a "No Name" category in the All of Memory table.
- Fixed issues with selecting array objects, or objects that had managed fields with arrays, when the arrays where multidimensional with one or more dimensions of size 0.
- Fixed exception when opening the Unity Objects table in Comparison mode when there are multiple MonoBehaviour or ScriptableObject types with the same name but from different assemblies.
- Fixed exception when opening the All Of Memory table in Comparison mode when either of the snapshots is from a pre 2022.2 runtime and the untracked amount is negative.
- Fixed an ArgumentOutOfRangeException when inspecting some Managed Objects ([PROFB-223](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-223)).
- Fixed longer string values not being displayed in the Managed Fields Inspector.
- Fixed an issue that caused IL2CPP VM memory to not be calculated correctly in the Summary and All Of Memory table.
- Remove deprecated UxmlFactory/UxmlTraits API usage on Unity 6.
- Add divider on "Capture" toolbar button dropdown.
- Reattributed IL2CPP VM memory from Native to Managed in the All Of Memory table.

### Changed
- Documentation updated.
- The "Search In Project" button now searches in the Assets folder _and_ in Packages (related to ([PROFB-54](https://issuetracker.unity3d.com/product/unity/issues/guid/PROFB-54))).
- Improved the performance of selecting items in the All Of Memory and Unity Objects tables for objects with managed memory. This affected in particular objects which have a lot of entries (their own or nested fields) displayed in their Managed Fields in the Selection Details panel. Beyond improving the performance in general, 'Continue...' entries, which can be clicked to get further entries added to the view, now not only appear in fields 4 layers down and for big arrays, but also after a total of 1000 field entries have been added to the view.
- Allowed Snapshots to reside in Subfolders within the configured memory snapshot path.
- Improved Snapshots folder monitoring: Changes to the folder are now reflected in the Editor without it requiring to acquire focus first.
- Improved display of managed arrays in the Selected Item Details and Managed Fields.

For a full list of changes and updates in this version, see the [Memory Profiler Changelog](xref:changelog).
27 changes: 26 additions & 1 deletion Editor/Containers/DynamicArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ unsafe interface ILongIndexedContainer<T> : IEnumerable<T>
/// </summary>
/// <typeparam name="T"></typeparam>
[StructLayout(LayoutKind.Sequential)]
unsafe readonly struct DynamicArrayRef<T> : ILongIndexedContainer<T> where T : unmanaged
unsafe readonly struct DynamicArrayRef<T> : IEquatable<DynamicArrayRef<T>>, ILongIndexedContainer<T> where T : unmanaged
{
[NativeDisableUnsafePtrRestriction]
readonly T* m_Data;
Expand Down Expand Up @@ -79,6 +79,31 @@ unsafe DynamicArrayRef(T* data, long lendth, bool isCreated)
public readonly IEnumerator<T> GetEnumerator() => new DynamicArrayEnumerator<T>(this);

readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

public readonly int GetHashCode(DynamicArrayRef<T> obj) => obj.GetHashCode();

public override int GetHashCode()
{
if (!IsCreated || Count == 0)
return HashCode.Combine(Count, IsCreated);
var hash = this[0].GetHashCode();
for (long i = 1; i < Count; i++)
{
hash = HashCode.Combine(hash, this[i]);
}
return hash;
}

public readonly bool Equals(DynamicArrayRef<T> other)
{
if (m_Data == other.m_Data)
return true;

if (Count != other.Count)
return false;

return UnsafeUtility.MemCmp(m_Data, other.m_Data, UnsafeUtility.SizeOf<T>() * Count) == 0;
}
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Editor/Containers/DynamicBlockArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ unsafe struct MemBlock
public void* mem;
}

unsafe struct DynamicBlockArray<T> : IDisposable where T : struct
unsafe struct DynamicBlockArray<T> : IDisposable where T : unmanaged
{
public const int k_InitialBlockSlots = 8;
MemBlock* m_BlockList;
Expand Down Expand Up @@ -59,7 +59,7 @@ public uint Capacity

public DynamicBlockArray(int blockSize, int initialCapacity)
{
Checks.CheckEquals(true, UnsafeUtility.IsBlittable<T>());
Checks.CheckEquals(true, UnsafeUtility.IsUnmanaged<T>());
m_BlockSize = blockSize;
uint preAllocatedBlockCount = ComputeBlockCount((uint)initialCapacity, m_BlockSize);
m_Capacity = preAllocatedBlockCount * (uint)m_BlockSize;
Expand Down
Loading

0 comments on commit 472f2a0

Please sign in to comment.