AutoMapper is taking too much memory. I think it's a memory leak.
I'm using 11.0.1 version in.Net Core 6 framework.
I've profiled the project. Here are a couple of screenshots:
Memory Usage reaches up to 2 GB by the Web API
Any ideas as to why it is taking this much memory for around 400 mapping classes?
Here's the configuration of AutoMapper being applied from the static IServiceCollection class:
services.AddAutoMapper( cfg => cfg.AddMaps("WebApi.Common"), typeof(MapperProfile), typeof(VendorProfile));
enter code here
I fixed it by configuring AutoMapper according to the latest documentation.
Below is the code that fixed this issue:
var mapperConfig = new MapperConfiguration(mc => { mc.AddMaps("WebApi.Common"); mc.AddMaps("WebApi.Core"); }); IMapper mapper = mapperConfig.CreateMapper(); services.AddSingleton(mapper);
Previously, it was configured according to the documentation of an older version of AutoMapper.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.