using System; using System.Runtime.InteropServices; using System.Security; using System.Diagnostics; public class Test { const int num_calls = 1000000; [DllImport("native", EntryPoint="clEnqueueNDRangeKernel")] public extern static unsafe int EnqueueNDRangeKernel( IntPtr command_queue, IntPtr kernel, Int32 work_dim, IntPtr* global_work_offset, IntPtr* global_work_size, IntPtr* local_work_size, Int32 num_events_in_wait_list, IntPtr* event_wait_list, out IntPtr newEvent); public static void Main() { Console.WriteLine(GC.GetTotalMemory(false)); Console.WriteLine(GC.GetTotalMemory(false)); DoIt(); Console.WriteLine(GC.GetTotalMemory(false)); DoIt(); Console.WriteLine(GC.GetTotalMemory(false)); DoIt(); Console.WriteLine(GC.GetTotalMemory(false)); } unsafe static void DoIt() { for (int i = 0; i < 1000000; i++) { IntPtr e; EnqueueNDRangeKernel( IntPtr.Zero, IntPtr.Zero, 0, null, null, null, 0, null, out e); } } }