使用xmpp到GCM服务器的JVM内存

时间:2015-01-07 16:50:35

标签: java android xmpp google-cloud-messaging

我为GCM开发了一个服务器端,接受来自Android的上游 - &gt; GCM - &gt;基于此Project的服务器,并将来自我的服务器tog com的消息发送到android。 (我使用Smack341.jar,发送和接收而不使用“chat”对象我通过自定义函数直接发送到GCM,这些函数从My Map&lt;&gt;创建JSON消息) 我修改了很多东西: 1.我的消息不是平面文本,而是包含15个字段的MAP。 2.没有直接连接到xmpp,所有通信都是通过GCM服务器完成的。 3.my Server获取目标regID(我的一个消息字段)并将消息发送到该RegId。 4.我添加了Filter类,读取字段调用(M_type =消息类型)包含我自己的类型(不是xmpp类型),即在线状态类型键入类型,stoptyping类型getFriendsList类型等...服务器根据这些类型行为:< / p>

  switch (  msg.getPayload().get(Constants.TYPECLM)) {
   case  Constants.GETFRIENDS: //get friends list...
     filter.Sendfriebdlist(msg.getPayload(),ccsClient);
     break;

    case Constants.ADDFRIEND:
           String Toregid=msg.getPayload().get(Constants.TO_CLM);
           filter.HandleFriendReq(msg.getPayload(),msg,ccsClient,Toregid);
           break;

 case Constants.ADDFRIENDRESPOND:
   filter.HandleAddFriendResond(msg, ccsClient, msg.getPayload().get(Constants.TO_CLM)); 
   break;        
 case "ACKBACK":
           filter.HandleAckfromU2U(ccsClient, msg.getPayload(),filter.key2reg(msg.getPayload().get(Constants.TO_CLM)));
           break;

        case "text":
           filter.HandleMsg(msg.getPayload(),msg,ccsClient,filter.key2reg(TorDevice));
           SendAckBack(msg.getFrom(),ccsClient,msg.getPayload().get(Constants.MESSAGE_ID_CLM));
           break;

        case "IMAGE":
           msg.getPayload().put(Constants.TO_CLM,filter.key2reg(msg.getPayload().get(Constants.TO_CLM)));
           String url = msg.getPayload().get(Constants.URLCLM);
           url ="http:/"+"/"+ url;
           url=url.replace("\\","/");
           System.out.println("image url = " +url);
          msg.getPayload().put(Constants.URLCLM,url);
           SendAckBack(msg.getFrom(),ccsClient,msg.getPayload().get(Constants.MESSAGE_ID_CLM));
           filter.HandleMsg(msg.getPayload(),msg,ccsClient,filter.key2reg(TorDevice)); 
           break;

   case "PROFILE":
    msg.getPayload().put(Constants.TO_CLM,filter.key2reg(msg.getPayload().get(Constants.TO_CLM)));
        String urlP = msg.getPayload().get(Constants.URLCLM);
          urlP ="http:/"+"/"+urlP;
           urlP=urlP.replace("\\","/");
   System.out.println(" URLCLM= "+msg.getPayload().get(Constants.URLCLM));      
msg.getPayload().put(Constants.URLCLM,urlP);         
 filter.updatePhoto( msg.getPayload(),ccsClient,msg);
   break;

   case "VIDEO":
           msg.getPayload().put(Constants.TO_CLM,filter.key2reg(msg.getPayload().get(Constants.TO_CLM)));
           String url2 = msg.getPayload().get(Constants.URLCLM);

            url2 ="http:/"+"/"+ url2;
           url2=url2.replace("\\","/");
           System.out.println("video url = " +url2);
           msg.getPayload().put(Constants.URLCLM,url2);
           SendAckBack(msg.getFrom(),ccsClient,msg.getPayload().get(Constants.MESSAGE_ID_CLM));
            filter.HandleMsg(msg.getPayload(),msg,ccsClient,filter.key2reg(TorDevice));
           break;

   case "AUDIO":
            msg.getPayload().put(Constants.TO_CLM,filter.key2reg(msg.getPayload().get(Constants.TO_CLM)));
           String url3 = msg.getPayload().get(Constants.URLCLM);
             url3 ="http:/"+"/"+ url3;
           url3=url3.replace("\\","/");
         msg.getPayload().put(Constants.URLCLM,url3);
           SendAckBack(msg.getFrom(),ccsClient,msg.getPayload().get(Constants.MESSAGE_ID_CLM));
            filter.HandleMsg(msg.getPayload(),msg,ccsClient,filter.key2reg(TorDevice));
        break;

   case "BLOCK":
       filter.block(msg.getPayload().get(Constants.FROMCLM),msg.getPayload().get(Constants.TO_CLM),ccsClient);
           break;

   case "UNBLOCK":
       filter.unblock(msg.getPayload().get(Constants.FROMCLM),msg.getPayload().get(Constants.TO_CLM),ccsClient);
           break;   

   case "REMOVE":
       filter.removef(msg.getPayload().get(Constants.FROMCLM),msg.getPayload().get(Constants.TO_CLM),ccsClient);
           break;

   case "typing":
       System.err.println("Typing");
       //filter.sendtyping(msg.getPayload().get(filter.key2reg(Constants.TO_CLM)),filter.key2reg(msg.getPayload().get(Constants.TO_CLM)),ccsClient,msg.getPayload());
           break;    
        case "stoptyping":
      // filter.sendStoptyping(filter.key2reg(msg.getPayload().get(Constants.TO_CLM)),filter.key2reg(msg.getPayload().get(Constants.TO_CLM)),ccsClient,msg.getPayload());
           System.err.println("Stop Typing");
            break;  

问题:1 我认为xmpp服务器有一个用户(GCM),他“不知道我有几百个!!

但是当用户开始互动(通过他们的Android设备聊天)并且上传的消息数量增加时,我的内存出错了...

java.lang.OutOfMemoryError: GC overhead limit exceeded

OR

java.lang.OutOfMemoryError: Java heap space 

有时:

Exception in thread "Smack Packet reader(0)" java.lang.OutOfMemoryError Java heap space

我的服务器设备有4GB物理RAM。我在3gb上运行我的服务器作为最大内存大小:

java  -Xms1024m -Xmx3072m -jar newsrvrSodfa.jar

我不知道为什么我会出现内存错误。可能数据类型只是MAP

问题:2 xmpp花了大约10-20秒(interceptPacket)!!

我希望我成功地描述了我的问题。问我有什么不清楚。

更新 1.服务器本身在Windows Server 2008 R2标准上 2.错误输出:

 at javax.swing.text.GapContent.getChars(Unknown Source)
        at javax.swing.text.AbstractDocument.getText(Unknown Source)
        at javax.swing.text.GlyphView.getText(Unknown Source)
        at javax.swing.text.GlyphView.getBreakSpot(Unknown Source)
        at javax.swing.text.GlyphView.getMinimumSpan(Unknown Source)
        at javax.swing.text.ParagraphView.calculateMinorAxisRequirements(Unknown Source)
        at javax.swing.plaf.basic.BasicTextAreaUI$PlainParagraph.calculateMinorAxisRequirements(Unknown Source)
        at javax.swing.text.BoxView.checkRequests(Unknown Source)
        at javax.swing.text.BoxView.getMinimumSpan(Unknown Source)
        at javax.swing.text.BoxView.calculateMinorAxisRequirements(Unknown Source)
        at javax.swing.text.BoxView.checkRequests(Unknown Source)
        at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
        at javax.swing.text.BoxView.layout(Unknown Source)
        at javax.swing.text.BoxView.setSize(Unknown Source)
        at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
        at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
        at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(Unknown Source)
        at javax.swing.JComponent.getPreferredSize(Unknown Source)
        at javax.swing.JTextArea.getPreferredSize(Unknown Source)
        at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
        at java.awt.Container.layout(Unknown Source)
        at java.awt.Container.doLayout(Unknown Source)
        at java.awt.Container.validateTree(Unknown Source)
        at java.awt.Container.validate(Unknown Source)
        at javax.swing.RepaintManager$3.run(Unknown Source)
        at javax.swing.RepaintManager$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
        at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
        at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  

线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:超出GC开销限制   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java堆空间   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java堆空间   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:超出GC开销限制   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java堆空间   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:超出GC开销限制   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java堆空间   线程“AWT-EventQueue-0”中的异常java.lang.OutOfMemoryError:Java堆空间

0 个答案:

没有答案