代码 
using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Collections; using System.Threading; 
namespace test 

    class Program 
    {         static void Main(string[] args) 
        {                     for (int i = 0; ; i++) 
            {                 try 
                { 
                    ceshi ch = new ceshi(); 
                    //ch.dispose(); 
                
                  //  th.Abort(); 
                  //  Thread.Sleep(1000); 
                    Console.WriteLine(">>"+i); 
                } 
                catch(Exception ex) 
                { 
                  
                    Console.WriteLine(ex.ToString()); 
                    break; 
                }             } 
            Console.Read(); 
        } 
    } 
    class ceshi 
    { 
        public Thread th; 
        public ceshi() 
        { 
            th = new Thread(f); 
            th.Start(); 
        } 
        void f() 
        { 
            int k = 0;             while (true) 
            { 
                k++; 
                Thread.Sleep(1000); 
                //if (k == 10) 
                //{ 
                //    break; 
                //} 
            } 
        } 
        public void dispose() 
        { 
            th.Abort(); 
        } 
        ~ceshi() 
        { 
            th.Abort(); 
        } 
    }     
    

当跑到第1862(不同机器不一样) 时候,就报System.OutOfMemoryException  错误 
根本不是电脑内存不够,程序才吃到50M 左右  我电脑4G内存 
这到底怎么回事啊 
怎么解决这个问题 求高手相助啊
因为我的程序需要启动很多线程

解决方案 »

  1.   

    我的有个大应用里面需要启动很多线程
    结果现在用户一多 就出现 System.OutOfMemoryException   这个错误
    不知道这什么意思
    也从没听说 线程数有限制啊没人知道吗
      

  2.   

    你这个线程数未免也太多了吧,你不知道线程都有计划生育的么?我觉得你的程序占用的内存应该不止50M,你应该看下任务管理器里的性能那一列显示的当前值是否达到了限制制,如果达到了,电脑反应就相当的慢,以至于长时间得不到内存就over了。