Forum Discussion

BuaChuan's avatar
BuaChuan
Copper Contributor
Nov 08, 2022

Memory<T> How to wrap references unmanaged memory?

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

  • LanHuang's avatar
    LanHuang
    Former Employee

    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

  • BuaChuan's avatar
    BuaChuan
    Copper Contributor

    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 

Resources