question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update IdentityModel dependency

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I would like to configure the OpenIdConnectOptions for each request. As the OpenIdConnectHandler requires an IOptionsMonitor (singleton), I registered the services as scoped like this:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IOptionsMonitor<OpenIdConnectOptions>, OptionsMonitor<OpenIdConnectOptions>>();
builder.Services.AddScoped<IOptionsMonitorCache<OpenIdConnectOptions>, OptionsCache<OpenIdConnectOptions>>();

It seems from .NET 6, this way of doing things causes a memory leak (the memory keeps growing):

NET 6 For my test, I simply inject an instance of IOptionsMonitor<OpenIdConnectOptions> into a controller and run a bench (a few hundred requests)

.NET 5 results (same test):

NET 5

It seems also that the issue only concerns OpenIdConnectOptions (but maybe not) because I tried with a custom options class and I didn’t notice any issue.

Expected Behavior

Same behavior as .NET 5

Steps To Reproduce

The repo to reproduce the issue: https://github.com/ylabade/options-memory-leak

Exceptions (if any)

No response

.NET Version

6.0.101

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Jan 21, 2022

The good news is that updating the dependency in AspNetCore servicing isn’t required, customers can update the IdentityModel dependency locally.

1reaction
Tratchercommented, Jan 20, 2022

@sebastienros IdentityModel doesn’t have a good track record with breaking changes, we’d definitely want to test this in 7.0 first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - updating Microsoft IdentityModel packages to 6.23x ...
Anyone experience an unexpected issue when upgrading your IdentityModel package dependencies? Is this a "bug" or is there another way to get ...
Read more >
IdentityModel 6.1.0
Version Downloads Last updated 6.1.0 1,835,027 4 months ago 6.1.0‑preview.6 5,951 5 months ago 6.1.0‑preview.5 6,047 5 months ago
Read more >
Nuget package dependency problem Microsoft.IdentityModel ...
This article provides a resolution to a problem with Nuget package dependencies for Microsoft.IdentityModel.Tokens.Jwt with the upgrade to ...
Read more >
Microsoft Security Advisory 3214296
IdentityModel.Tokens is a direct dependency. Update its version to 5.1.1 to download a version of this package that isn't affected.
Read more >
Volo.Abp.IdentityModel
Install -Package Volo.Abp.IdentityModel. Then add the AbpIdentityModelModule dependency to your module class as shown in the following example: using Volo.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found