-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers
Milestone
Description
| writer._writer.Reset(); |
With Reset only the internal state is reset, but the output remains the same (cf. code).
So the IBufferWriter<byte> that is set in Rent will be referenced by the (pooled) Utf8JsonWriter, so the lifetime for the IBufferWriter<byte> is bound to the pooled Utf8JsonWriter -- at least until the next Rent when a new one is set. Thus the IBufferWriter<byte> can't be GCed.
In the STJ internal type Utf8JsonWriterCache an internal method is used to reset the output too.
I'm just curios if the extended lifetime is a latent problem or not.
Possible mitigations could be:
Dispose-- not really, as the instance can't be re-used thenReset(Stream.Null)-- solves the lifetime problem, but allocates- reset by setting to a null-IBufferWriter (type needs to be created)
- ?
- make
Utf8JsonWriter.ResetAllStateForCacheReusepublic-- but this doesn't play nice with the disposal checks in that type
#9607 introduced the ReusableUtf8JsonWriter.
Metadata
Metadata
Assignees
Labels
area-signalrIncludes: SignalR clients and serversIncludes: SignalR clients and servers