Memory<T> How to wrap references unmanaged memory?

Copper Contributor

Span<T> can pass void* through the constructor to refer to unmanaged Memory, but what about Memory<T>? I didn't find a Mothod to do that.  IMemoryOwner<T> contains an property of type Memory<T>. If Memory<T> could wrap references to managed or unmanaged memory, it would be more generic, wouldn't it?

2 Replies

@BuaChuan

Why is the document written this way? Can Memory<T> actually reference unmanaged memory? What did I miss?

link:https://learn.microsoft.com/en-us/dotnet/standard/memory-and-spans/memory-t-usage-guidelines 无标题.png

Hi @BuaChuan,

Thanks for posting your issue here.

However this platform is used for how-to discussions and sharing best practices for building any app with .NET.Since your issue is a technical question, welcome to post it in Microsoft Q&A forum, the support team and communities on Microsoft Q&A will help you for any technical questions.
Besides, it will be appreciated if you can share it here once you post this technical question Microsoft Q&A.
Best Regards,
Lan Huang