Skip to content

ResourceManagerStringLocalizerFactory allocates too much #1264

@sebastienros

Description

@sebastienros

Here is an allocations snapshot for 50 requests of a sample web page rendering a blog post. It allocates more attributes than strings. More than 3MB of allocations for 50 requests (it depends on how many times the service is resolved).

image

The issue is in the Create method of this factory, which is called for every component that resolves an IStringLocalizer from DI, the result is cached, but creating the key of the cache entry is doing uncached reflection.

We could either cache by the type itself, or cache the reflection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions