dotnet / dotnet/dotnet-api-docs

How to allocate 2 or more GB ?

Open
#892 0 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime.InteropServices dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

The size parameter to the allocation is defined as an int. This precludes allocations of 2 or more GB in a single call. At the very least, the 'int cb' should have been a 'uint cb'.

I would also argue that in 64-bit addressing it should be a long (or a ulong)... welcome to the 64-bit world.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: ec1aaf4e-d08b-7d7b-a2bb-6e5cdbba5552
* Version Independent ID: 62bc5f30-97ac-bc21-47e2-7c4faffe602e
* Content: [Marshal.AllocCoTaskMem(Int32) Method (System.Runtime.InteropServices)](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.alloccotaskmem?view=netframework-4.7.2)
* Content Source: [xml/System.Runtime.InteropServices/Marshal.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Runtime.InteropServices/Marshal.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.