Skip to content

Commit

Permalink
Merge pull request #231 from DennisvHest/229-memory-increases-over-time
Browse files Browse the repository at this point in the history
Fixed memory leak with playlist cover images
  • Loading branch information
DennisvHest authored Dec 22, 2024
2 parents 13e98f3 + e3802c1 commit b771ce1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 1 addition & 0 deletions MapMaven/MapMaven.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.42</WindowsSdkPackageVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<WindowsPackageType>None</WindowsPackageType>
</PropertyGroup>
Expand Down
11 changes: 1 addition & 10 deletions MapMaven/Services/Playlists/PlaylistCoverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
using Microsoft.VisualStudio.Threading;
using System.Reactive.Linq;
using MapMaven.Extensions;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace MapMaven.Services.Playlists
{
public class PlaylistCoverService
{
private Dictionary<Playlist, AsyncLazy<string>> _cachedCoverImages = new(new CachedPlaylistEqualityComparer());
private Dictionary<Playlist, AsyncLazy<string>> _cachedCoverImages = new();

public PlaylistCoverService(IMapService mapService, IPlaylistService playlistService, IBeatSaberDataService beatSaberDataService)
{
Expand Down Expand Up @@ -81,11 +79,4 @@ public async Task<string> GetCoverImageAsync(Playlist playlist)
return null;
}
}

public class CachedPlaylistEqualityComparer : IEqualityComparer<Playlist>
{
public bool Equals(Playlist x, Playlist y) => ReferenceEquals(x, y);

public int GetHashCode([DisallowNull] Playlist obj) => RuntimeHelpers.GetHashCode(obj);
}
}

0 comments on commit b771ce1

Please sign in to comment.