-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
Description
I've enabled in my ASP.NET Core project the usage of the built-in ReferenceHandler as following.
services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.Converters.Add(new TimeSpanConverter());
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve;
});I've observed my process, which was previously running with a memory consuption of 110-120Mb, running at over 2GB (and increasing) a few seconds minutes after I've connected my client. My client is a C# client generated with NSwag.
Configuration
- NET 5.0
- Windows 10 v20H2 build 19042.746
- Architecture x64
Other information
I've tried to have a look at source code and I see PreserveReferenceHandler have a static reference (ReferenceHandler.cs) and contains a dictionary from which values are never removed (PreserveReferenceResolver.cs).. So I can just guess disposing would occur when the whole serializer is disposed but it's not clear to me when this happens.
Am I using it in a wrong way?
Thanks in advance for any help.
Dan