dotnet / dotnet/dotnet-api-docs
Missing reference on `Finalize` declaration
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Type of issue
Typo
### Description
From https://learn.microsoft.com/en-us/dotnet/api/system.buffers.imemoryowner-1?view=net-8.0
> Because the IMemoryOwner object implements the [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-8.0) interface, you should call its [Dispose](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose?view=net-8.0) method only after the memory buffer is no longer needed and you have destroyed it. You should not dispose of the IMemoryOwner object while a reference to its memory is available. This means that the type in which IMemoryOwner is declared should not have a [Finalize](https://learn.microsoft.com/en-us/dotnet/api/system.object.finalize?view=net-8.0) method.
If I remember correctly, runtime does not gurantee validity of reference in `Finalize` method because object collection order is unpredictable for user code. I guess this _Remarks_ points out some more important feature of `Memory` which makes it highly unsuitable candidate for usage in `Finalize` method. Thus some reference on this would be helpful.
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.buffers.imemoryowner-1?view=net-8.0
### Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Buffers/IMemoryOwner`1.xml
### Document Version Independent Id
f2f96c55-4bde-4c03-4f21-1c27a1e3a154
### Article author
@dotnet-bot
Contributor guide
Assessment
This issue has not been assessed yet.