From a6382026941b8d6e9c84fefa6de6378a1e7cd115 Mon Sep 17 00:00:00 2001 From: pschraut Date: Wed, 6 Nov 2024 19:45:21 +0100 Subject: [PATCH 1/5] Fixed compile errors starting with Unity 2022.2. This commit also addresses PR #16 --- CHANGELOG.md | 3 ++- Editor/Scripts/HeapExplorerWindow.cs | 12 +++++++++--- Tests/Editor/Test_Editor.cs | 10 ++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4a429..3846660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ All notable changes to this package are 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). -## [4.1.2] - 202?-??-?? +## [4.1.2] - 2024-??-?? ### Fixed + - Fixed compile errors starting with Unity 2022.2. This also addresses PR #16 (Thanks Chris) - Fixed ```ComputeConnectionKey``` possibly causing an overflow and showing wrong connections. Thanks to Yi Ji for sending me the fix. - Fixed ```IndexOutOfRangeException``` when capturing a memory snapshot that contains obfuscated code. Thanks to UlyssesWu for the fix. See [PR#14](https://github.com/pschraut/UnityHeapExplorer/pull/14) for details. diff --git a/Editor/Scripts/HeapExplorerWindow.cs b/Editor/Scripts/HeapExplorerWindow.cs index 277a026..675ba6d 100644 --- a/Editor/Scripts/HeapExplorerWindow.cs +++ b/Editor/Scripts/HeapExplorerWindow.cs @@ -1,5 +1,5 @@ // -// Heap Explorer for Unity. Copyright (c) 2019-2020 Peter Schraut (www.console-dev.de). See LICENSE.md +// Heap Explorer for Unity. Copyright (c) 2019-2024 Peter Schraut (www.console-dev.de). See LICENSE.md // https://github.com/pschraut/UnityHeapExplorer/ // #pragma warning disable 0414 @@ -10,6 +10,12 @@ using System; using System.Threading; +#if UNITY_2022_2_OR_NEWER +using UnityMemoryProfiler = Unity.Profiling.Memory.MemoryProfiler; +#else +using UnityMemoryProfiler = UnityEngine.Profiling.Memory.Experimental.MemoryProfiler; +#endif + namespace HeapExplorer { public class HeapExplorerWindow : EditorWindow @@ -801,7 +807,7 @@ void CaptureAndSaveHeap() m_IsCapturing = true; string snapshotPath = System.IO.Path.ChangeExtension(path, "snapshot"); - UnityEngine.Profiling.Memory.Experimental.MemoryProfiler.TakeSnapshot(snapshotPath, OnHeapReceivedSaveOnly); + UnityMemoryProfiler.TakeSnapshot(snapshotPath, OnHeapReceivedSaveOnly); } finally { @@ -847,7 +853,7 @@ void CaptureAndAnalyzeHeap() m_IsCapturing = true; var path = FileUtil.GetUniqueTempPathInProject(); - UnityEngine.Profiling.Memory.Experimental.MemoryProfiler.TakeSnapshot(path, OnHeapReceived); + UnityMemoryProfiler.TakeSnapshot(path, OnHeapReceived); } finally { diff --git a/Tests/Editor/Test_Editor.cs b/Tests/Editor/Test_Editor.cs index b894bac..8b211df 100644 --- a/Tests/Editor/Test_Editor.cs +++ b/Tests/Editor/Test_Editor.cs @@ -1,5 +1,5 @@ // -// Heap Explorer for Unity. Copyright (c) 2019-2022 Peter Schraut (www.console-dev.de). See LICENSE.md +// Heap Explorer for Unity. Copyright (c) 2019-2024 Peter Schraut (www.console-dev.de). See LICENSE.md // https://github.com/pschraut/UnityHeapExplorer/ // #pragma warning disable 0414 @@ -12,6 +12,12 @@ using System.Collections; using System.Collections.Generic; +#if UNITY_2022_2_OR_NEWER +using UnityMemoryProfiler = Unity.Profiling.Memory.MemoryProfiler; +#else +using UnityMemoryProfiler = UnityEngine.Profiling.Memory.Experimental.MemoryProfiler; +#endif + namespace HeapExplorer { interface ITestInterface @@ -42,7 +48,7 @@ public Test_Editor() public IEnumerator Capture() { var path = FileUtil.GetUniqueTempPathInProject(); - UnityEngine.Profiling.Memory.Experimental.MemoryProfiler.TakeSnapshot(path, OnSnapshotReceived); + UnityMemoryProfiler.TakeSnapshot(path, OnSnapshotReceived); var timeout = Time.realtimeSinceStartup + 15; while (m_snapshot == null) From 8bfa83d5f52076d6615edb0f552df4a4419b2fb8 Mon Sep 17 00:00:00 2001 From: pschraut Date: Wed, 6 Nov 2024 19:55:15 +0100 Subject: [PATCH 2/5] bumped version to 4.2.0 --- CHANGELOG.md | 2 +- LICENSE.md | 2 +- README.md | 7 +++---- package.json | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3846660..16ab3bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this package are 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). -## [4.1.2] - 2024-??-?? +## [4.2.0] - 2024-11-06 ### Fixed - Fixed compile errors starting with Unity 2022.2. This also addresses PR #16 (Thanks Chris) - Fixed ```ComputeConnectionKey``` possibly causing an overflow and showing wrong connections. Thanks to Yi Ji for sending me the fix. diff --git a/LICENSE.md b/LICENSE.md index c1b6596..b813421 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2022 Peter Schraut (http://www.console-dev.de) +Copyright (c) 2019-2024 Peter Schraut (http://www.console-dev.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index a9cf3ee..5886b2a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Introduction -Heap Explorer is a Memory Profiler, Debugger, and Analyzer for Unity. This repository hosts Heap Explorer for Unity 2019.3 and newer versions. For older versions, please visit the obsolete repository on Bitbucket instead ([link](https://bitbucket.org/pschraut/unityheapexplorer/)). +Heap Explorer is a Memory Profiler, Debugger, and Analyzer for Unity 2019 up to Unity 6. I have spent a significant amount of time in the past identifying and fixing memory leaks, as well as searching for memory optimization opportunities in Unity applications. During this time, I often used Unity's [old Memory Profiler](https://bitbucket.org/Unity-Technologies/memoryprofiler). While it's a useful tool, I was never entirely satisfied with it. @@ -12,15 +12,13 @@ After much consideration about what to do with Heap Explorer, I concluded that t Since then, I have provided occasional updates because several people still prefer Heap Explorer over Unity's Memory Profiler due to its easier-to-understand UI/UX. -I have also updated Heap Explorer to work with Unity 2019.3 and converted it into a Package, which means you should be able to use Heap Explorer for the entire 2019 LTS cycle, which ends in 2022. +I do however recommend to install Unity's own Memory Profiler, because I believe it's superior in various ways to Heap Explorer now in the year 2024. [![](http://img.youtube.com/vi/tcTl_7y8JBA/0.jpg)](https://www.youtube.com/watch?v=tcTl_7y8JBA "") # Installation -In order to use the Heap Explorer, you have to add the package to your project. As of Unity 2019.3, Unity supports to add packages from git through the Package Manager window. - In Unity's Package Manager, choose "Add package from git URL" and insert one of the Package URL's you can find below. Once Heap Explorer is installed, you can open it from Unity's main menu under "Window > Analysis > Heap Explorer". @@ -32,6 +30,7 @@ Please see the ```CHANGELOG.md``` file to see what's changed in each version. | Version | Link | |----------|---------------| +| 4.2.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.2.0 | | 4.1.1 | https://github.com/pschraut/UnityHeapExplorer.git#4.1.1 | | 4.1.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.1.0 | | 4.0.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.0.0 | diff --git a/package.json b/package.json index 9a2b360..78e7ae9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.oddworm.heapexplorer", - "version": "4.1.2", + "version": "4.2.0", "displayName": "Heap Explorer", "description": "Heap Explorer is a Memory Profiler, Debugger and Analyzer for Unity. You can open it from the main menu 'Window > Analysis > Heap Explorer'.", "documentationUrl": "https://github.com/pschraut/UnityHeapExplorer", From 369b3b492c011194c3504551f0e9a47b84e3100d Mon Sep 17 00:00:00 2001 From: pschraut Date: Wed, 6 Nov 2024 20:00:07 +0100 Subject: [PATCH 3/5] Fixed version number --- Editor/Scripts/HeGlobals.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/Scripts/HeGlobals.cs b/Editor/Scripts/HeGlobals.cs index a5b6ddf..694ec03 100644 --- a/Editor/Scripts/HeGlobals.cs +++ b/Editor/Scripts/HeGlobals.cs @@ -1,5 +1,5 @@ // -// Heap Explorer for Unity. Copyright (c) 2019-2021 Peter Schraut (www.console-dev.de). See LICENSE.md +// Heap Explorer for Unity. Copyright (c) 2019-2024 Peter Schraut (www.console-dev.de). See LICENSE.md // https://github.com/pschraut/UnityHeapExplorer/ // using System.Collections; @@ -11,7 +11,7 @@ namespace HeapExplorer public static class HeGlobals { public const string k_Title = "Heap Explorer"; - public const string k_Version = "4.1"; + public const string k_Version = "4.2"; public const string k_DocuUrl = "https://github.com/pschraut/UnityHeapExplorer"; public const string k_ChangelogUrl = "https://github.com/pschraut/UnityHeapExplorer/blob/master/CHANGELOG.md"; public const string k_ForumUrl = "https://forum.unity.com/threads/wip-heap-explorer-memory-profiler-debugger-and-analyzer-for-unity.527949/"; From 8a7c0d11698a115a2a46f033477edcdeb1ab3276 Mon Sep 17 00:00:00 2001 From: pschraut Date: Thu, 21 Nov 2024 16:02:40 +0100 Subject: [PATCH 4/5] Fixed a memory leak that occurred when capturing an editor memory snapshot, then closing and reopening Heap Explorer to take another snapshot. This changeset resolves issue #17. --- CHANGELOG.md | 4 ++++ Editor/Scripts/HeapExplorerWindow.cs | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ab3bc..88dddbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this package are 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). +## [4.3.0] - 2024-??-?? +### Fixed + - Fixed a memory leak that occurred when capturing an editor memory snapshot, then closing and reopening Heap Explorer to take another snapshot. Thanks to marvelous007x for the report. See [Issue #17](https://github.com/pschraut/UnityHeapExplorer/issues/17) for details. + ## [4.2.0] - 2024-11-06 ### Fixed - Fixed compile errors starting with Unity 2022.2. This also addresses PR #16 (Thanks Chris) diff --git a/Editor/Scripts/HeapExplorerWindow.cs b/Editor/Scripts/HeapExplorerWindow.cs index 675ba6d..dda768e 100644 --- a/Editor/Scripts/HeapExplorerWindow.cs +++ b/Editor/Scripts/HeapExplorerWindow.cs @@ -187,6 +187,7 @@ void OnDisable() EditorApplication.update -= OnEditorApplicationUpdate; + CloseFile(); DestroyViews(); } From e2c2e916c78674fb7ce1855064f6af642cb9c671 Mon Sep 17 00:00:00 2001 From: pschraut Date: Thu, 21 Nov 2024 16:09:06 +0100 Subject: [PATCH 5/5] bumped version to 4.3.0 --- CHANGELOG.md | 2 +- Editor/Scripts/HeGlobals.cs | 2 +- README.md | 1 + package.json | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88dddbd..7486304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this package are 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). -## [4.3.0] - 2024-??-?? +## [4.3.0] - 2024-11-21 ### Fixed - Fixed a memory leak that occurred when capturing an editor memory snapshot, then closing and reopening Heap Explorer to take another snapshot. Thanks to marvelous007x for the report. See [Issue #17](https://github.com/pschraut/UnityHeapExplorer/issues/17) for details. diff --git a/Editor/Scripts/HeGlobals.cs b/Editor/Scripts/HeGlobals.cs index 694ec03..7cdb6d9 100644 --- a/Editor/Scripts/HeGlobals.cs +++ b/Editor/Scripts/HeGlobals.cs @@ -11,7 +11,7 @@ namespace HeapExplorer public static class HeGlobals { public const string k_Title = "Heap Explorer"; - public const string k_Version = "4.2"; + public const string k_Version = "4.3"; public const string k_DocuUrl = "https://github.com/pschraut/UnityHeapExplorer"; public const string k_ChangelogUrl = "https://github.com/pschraut/UnityHeapExplorer/blob/master/CHANGELOG.md"; public const string k_ForumUrl = "https://forum.unity.com/threads/wip-heap-explorer-memory-profiler-debugger-and-analyzer-for-unity.527949/"; diff --git a/README.md b/README.md index 5886b2a..bc24ca4 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Please see the ```CHANGELOG.md``` file to see what's changed in each version. | Version | Link | |----------|---------------| +| 4.3.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.3.0 | | 4.2.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.2.0 | | 4.1.1 | https://github.com/pschraut/UnityHeapExplorer.git#4.1.1 | | 4.1.0 | https://github.com/pschraut/UnityHeapExplorer.git#4.1.0 | diff --git a/package.json b/package.json index 78e7ae9..e0d6e03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.oddworm.heapexplorer", - "version": "4.2.0", + "version": "4.3.0", "displayName": "Heap Explorer", "description": "Heap Explorer is a Memory Profiler, Debugger and Analyzer for Unity. You can open it from the main menu 'Window > Analysis > Heap Explorer'.", "documentationUrl": "https://github.com/pschraut/UnityHeapExplorer",