Skip to content

Conversation

@rena0157
Copy link
Owner

@rena0157 rena0157 commented Jan 7, 2022

Adding lifetime options for registering Maps with the DI container. No breaking changes in this PR, only the addition to configure how your Maps are registered (Singleton, or Transient). Registering Maps as Singleton drastically reduces the amount of memory allocations in the process of running a map through the mapper.

Registered as Transient and calling mapper over many iterations causes a lot of GC time and allocation
image

Adding the [Map(Lifetime = MapLifetime.Singleton)] to the map now completely removes that allocation
image

The default behaviour of the registration is still to register maps as Transient, but I would highly recommend keeping maps as pure and register them as Singleton.

@rena0157 rena0157 merged commit edc47ab into main Jan 7, 2022
@rena0157 rena0157 deleted the adding-lifetime-options branch January 7, 2022 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants