using System;
using System.Runtime.InteropServices;
class Program
{
static void Main()
{
// Allocate 1MB = 1,048,576 bytes in unmanaged memory
IntPtr ptr = Marshal.AllocHGlobal(1024 * 1024);
Console.WriteLine("Allocated 1MB of unmanaged memory.");
Marshal.FreeHGlobal(ptr); // Free memory after use
}
}
/*
run:
Allocated 1MB of unmanaged memory.
*/