Memory<T> How to wrap references unmanaged memory?

陈百川 1 Reputation point
2022-11-11T02:03:29.19+00:00

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?
Can Memory<T> actually reference unmanaged memory? What did I miss?
Why is the document written this way? link:memory-t-usage-guidelines

259303-%E6%97%A0%E6%A0%87%E9%A2%98.png

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,846 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,152 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 31,011 Reputation points Microsoft Vendor
    2022-11-11T08:15:22.987+00:00

    Hi @陈百川 ,
    Please check if this helps.
    https://github.com/dotnet/corefxlab/blob/archive/docs/specs/memory.md
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.