你把presentPattern()函数写出来看看呢

解决方案 »

  1.   

    PresentPattern()太长了,帖不上阿,我想是不是我定义了太多的数组了,每个数组的长度都还不小,
      private  int NEURONS = 101;
      private  int WEIGHT = 735;
      static int times =50;  static double deltaWeight1[];
      static double deltaWeight2[];
      static double deltaWeight3[];
      static double deltaWeight4[];
      static double deltaWeight5[];
      static double deltaWeight6[];
      
      
      static double neurons1[];
      static double neurons2[];
      static double neurons3[];
      static double neurons4[];
      static double neurons5[];
      static double neurons6[];
      
      static double weight1[];
      static double weight2[];
      static double weight3[];
      static double weight4[];
      static double weight5[];
      static double weight6[];初始化  neurons1 = new double[NEURONS];
      randomizeFValues(neurons1);
                
      neurons2 = new double[NEURONS];
      randomizeFValues(neurons2);
          
      neurons3 = new double[NEURONS];
      randomizeFValues(neurons3);
          
      neurons4 = new double[NEURONS];
      randomizeFValues(neurons4);
          
      neurons5 = new double[NEURONS];
      randomizeFValues(neurons5);
          
      neurons6 = new double[NEURONS];
      randomizeFValues(neurons6);  weight1 = new double[WEIGHT];
      weight2 = new double[WEIGHT];
      weight3 = new double[WEIGHT];
      weight4 = new double[WEIGHT];
      weight5 = new double[WEIGHT];
      weight6 = new double[WEIGHT];
            
      randomizeWeight();
         
      deltaWeight1= new double[times*248] ;
      deltaWeight2= new double[times*248] ;
      deltaWeight3= new double[times*248] ;
      deltaWeight4= new double[times*248] ;
      deltaWeight5= new double[times*248] ;
      deltaWeight6= new double[times*248] ;用的时候就是通过计算,算出新的值,然后改变数组元素的值。如
    for(int j=0; j<735; j++)
    {
      weight1[0]+=deltaW1;
    }
            
    for(int j=0; j<735; j++)
    {
      weight2[0]+=deltaW2;
    }       
    ......neuron1[i]+=deltaF1;......对象怎样回收阿,我的确没写回收语句,恳请指教啦,急。
      

  2.   

    对象 = null 可以回收
      

  3.   

    这些一定要 static 吗?
    static double deltaWeight1[];
      static double deltaWeight2[];
      static double deltaWeight3[];
      static double deltaWeight4[];
      static double deltaWeight5[];
      static double deltaWeight6[];
      
      
      static double neurons1[];
      static double neurons2[];
      static double neurons3[];
      static double neurons4[];
      static double neurons5[];
      static double neurons6[];
      
      static double weight1[];
      static double weight2[];
      static double weight3[];
      static double weight4[];
      static double weight5[];
      static double weight6[];
      

  4.   

    如果是像你那样循环调用
    presentPattern
    这个化,用static成员也不错。但是要注意这些static成员一旦生成后除非你显示的置空,要不然只要有任何引用在你的包含有presentPattern(int)方法的类上面,它是一直不回释放的;而且用static成员会相互影响的哦。像这种问题,我个人觉得主要应该在算法上进行优化。当然调大内存也是一个简洁的解决之道。
      

  5.   

    我去掉了所有的static试了一下,没有改善阿。对象=null 不行阿,那样值就全丢了,这些数据是需要留着的,下次读取然后计算出新的,然后修改数组里的值。调大内存的方法网上有,比如,java -Xms64m -Xmx256m, 可为什么我用不好用,打完命令显示了几行字,再运行程序还是没变化,不知道是否VM被调大了。有调过VM的高人指教一下么,先谢过了。
      

  6.   

    你的机器有多大内存?
    运行期调整jvm参数应该是能在一定的范围内有效过的。
    -XX:MaxPermSize=64m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:SurvivorRatio=8 -Xms512m -Xmx512m
      

  7.   

    如果有些数组不用,那么把该数组设为null,然后使用System.gc()试一下
      

  8.   

    机器显示的是504M RAM, 奇怪,我想应该是512M吧,办公室的机器。