此代碼逐漸消耗內存,從大約130 MB開始(由于依賴性),并在我必須殺死它并重新啟動它(因為服務器內存不足)之前不斷爬升到800 + MB。它與OpenJDK 11一起運行。我有一個舊版本的代碼運行在Java 8服務器上,其內存使用率保持穩定并且永遠不會增加。所以我不確定它是否與新的JDK有關?我在這里修改了相當多的代碼,以確保它盡可能簡單 - 但仍然有問題?;疽c - 它是否每隔幾秒鐘查詢一次數據庫以查找待處理的發票。但是,沒有待處理的發票(日志也證明了這一點),因此它永遠不會進入復雜的代碼位置,而只會每隔幾秒鐘繼續重復一次。public static void main(String[] args) { ... final int interval = Constants.INTERVAL; QuickBooksInvoices qbInvoices = new QuickBooksInvoices(filename); qbInvoices.testConnection(); log.log(Level.INFO, "Checking invoices with an interval of " + interval + " seconds..."); while (isRunning == true) { qbInvoices.process(); try { Thread.sleep(interval * 1000); } catch (InterruptedException e) { } }}public void process() { errorBuffer.clear(); // These are array lists successBuffer.clear(); // These are array lists try (Connection conn = DriverManager.getConnection(dbURI, dbUser, dbPassword)) { ArrayList<com.xxx.quickbooks.model.wdg.Invoice> a = getInvoices(conn); OAuthToken token = null; if (a.size() > 0) { // Never gets here - no results } for (com.xxx.quickbooks.model.wdg.Invoice invoice : a) { // Never gets here - no results } } catch (Exception e) { writeLog(Level.ERROR, ExceptionUtils.getStackTrace(e)); }}private ArrayList<com.xxx.quickbooks.model.wdg.Invoice> getInvoices(Connection conn) { ArrayList<com.xxx.quickbooks.model.wdg.Invoice> invoices = new ArrayList<com.xxx.quickbooks.model.wdg.Invoice>(); String sql = "select " + "id," + "type," + "status," + "business_partner_id," + "invoice_number," + "total," + "nrc," + "szrc," + "trans_ts," + "warehouse_id," + "due_date," + "ref_number," + "payment_type " + "FROM dv_invoice " + "WHERE exported_ts is NULL AND exported_msg is NULL ; ";
添加回答
舉報
0/150
提交
取消