- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Thread thr = new Thread(new ThreadStart(testThread));
- thr.Start();
- //输出程序当前占用的内存量
- long memorysize = System.Diagnostics.Process.
- GetCurrentProcess().PagedMemorySize64;
- Console.WriteLine(string.Format(
- "PagedMemorySize:{0}MB", memorysize / (1024 * 1024)));
- Thread.Sleep(500);
- }
- }
- static void testThread()
- {
- LinkedList<IntPtr> l = new LinkedList<IntPtr>();
- l.AddLast(Marshal.AllocCoTaskMem(50000000));
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/3012201514341.html
来源: http://www.codesnippet.cn/detail/3012201514341.html