Skip to content

Conversation

@martindevans
Copy link
Member

@martindevans martindevans commented Feb 27, 2025

Depending on the CommunityToolkit.HighPerformance package and using MemoryOwner for management of buffer rentals.

Replaced almost all uses of ArrayPool, fixed one case where memory was rented but never returned.

Old content:
Introduced SpanRental and MemoryRental, which provide a safer API than ArrayPool.

  • Returns a Span or Memory, instead of an array
  • Returned buffer is exactly the requested size
  • Rental is returned as a disposable struct, if used with using it will always be disposed
  • No need to use try/finally everywhere

@martindevans
Copy link
Member Author

martindevans commented Mar 3, 2025

Alternatively we could depend on the CommunityToolkit.HighPerformance package and use MemoryOwner. Done this.

@martindevans martindevans merged commit c847215 into SciSharp:master Mar 15, 2025
6 checks passed
@martindevans martindevans deleted the memory_pooling_rental branch March 15, 2025 23:23
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.

1 participant