@Ignore @Test public void checkMemoryLeaks() throws Exception { List<String> dbUrls = new ArrayList<>(); dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: List<Ledger> ledgers = new ArrayList<>(); for (int it = 0; it < 100; it++) { if (it % 10 == 0) System.out.println("Iteration " + it); dbUrls.stream().forEach(url -> { try { clearLedger(url); PostgresLedger ledger = new PostgresLedger(url); ledgers.add(ledger); } catch (Exception e) { e.printStackTrace(); } }); TestSpace ts = prepareTestSpace(); ts.node.config.getAddressesWhiteList().add(new KeyAddress(TestKeys.publicKey(3), 0, true)); Contract testContract = new Contract(ts.myKey); testContract.seal(); assertTrue(testContract.isOk()); Parcel parcel = createParcelWithFreshU(ts.client, testContract, Do.listOf(ts.myKey)); ts.client.registerParcelWithState(parcel.pack(), 18000); Contract testContract2 = new Contract(ts.myKey); testContract2.seal(); assertTrue(testContract2.isOk()); ts.client.register(testContract2.getPackedTransaction(), 18000); ts.nodes.forEach(x -> x.shutdown()); ts.myKey = null; ts.nodes.clear(); ts.node = null; ts.nodes = null; ts.client = null; ts = null; ledgers.stream().forEach(ledger -> ledger.close()); ledgers.clear(); System.gc(); Thread.sleep(2000); } }
public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); static final String NODE_VERSION; final Reporter reporter; final BufferedLogger logger; public NetConfig netConfig; public NetworkV2 network; final Config config; public NodeInfo myInfo; public Node node; public ItemCache cache; public ParcelCache parcelCache; public PaidOperationCache paidOperationCache; }