服務啓動後一段時間內,忽然內存溢出:Exception in thread 「main」 java.lang.OutOfMemoryError: PermGen spacejava
第一想的就是jar依賴是否是互相依賴致使的,後來發現並非ide
很快找到觸發內存不夠的那段代碼,註釋掉工具
public void receivePrintResult() throws Exception { Properties properties = new Properties(); properties.setProperty(ConsumerConstants.MafkaBGNamespace, "daocan"); properties.setProperty(ConsumerConstants.MafkaClientAppkey, "orderdish-platform-print-service"); properties.setProperty(ConsumerConstants.SubscribeGroup, "orderdish-platform-print-service"); consumer = MafkaClient.buildConsumerFactory(properties, "owl_print_result_notify"); /* consumer.recvMessageWithParallel(String.class, new IMessageListener() { @Override public ConsumeStatus recvMessage(MafkaMessage mafkaMessage, MessagetContext messagetContext) { try { String result = (String) mafkaMessage.getBody(); System.out.print(result); INFO_LOG.info("resultResponse success:{}"+ result); printResultRedisService.analysePrintResult(result);//處理消息隊列 }catch (Exception e){ ERROR_LOG.error("mafka reseivePrintResult#fail Exception:{}",e); return ConsumeStatus.RECONSUME_LATER; } System.out.println("======================================="); return ConsumeStatus.CONSUME_SUCCESS; } });*/ }
採用jvisualvm.exe工具查看內存堆使用狀況:ui
能夠看出內存幾乎使用完成,致使內存溢出spa
配置 : -server -XX:PermSize=128M -XX:MaxPermSize=256m code
手動擴大內存解決問題orm