You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For hyper memory optimization, support a slice declaring itself as reusable so the slice factory can reuse instances rather than creating new ones each time. The slice would return itself to the pool after it renders each time (slices are considered "dead" after rendering today).
This is a bit scary, but for some scenarios might be advantageous.
The text was updated successfully, but these errors were encountered:
To use, simply add @implements IRazorReusableSlice to the top of your slice .cshtml file. You can optionally implement the bool TryReset() method if your slice has instance-level state it needs to clear before reuse.
Some initial results from adding support for this:
This image of the Visual Studio profiler (.NET Object Allocation Tracking) shows that (after warmup) the only thing allocated when rendering a reusable slice to a string 1000 times is the final string itself:
For hyper memory optimization, support a slice declaring itself as reusable so the slice factory can reuse instances rather than creating new ones each time. The slice would return itself to the pool after it renders each time (slices are considered "dead" after rendering today).
This is a bit scary, but for some scenarios might be advantageous.
The text was updated successfully, but these errors were encountered: