From 60b775e585c510b4f72e189f64a794773407ad17 Mon Sep 17 00:00:00 2001 From: ssardina Date: Sun, 16 Apr 2023 08:27:10 +1000 Subject: [PATCH 1/7] Gather mem consumption while search --- src/main/java/paladinus/PaladinusPlanner.java | 35 ++++++++++++++++--- .../iterative/IterativeDepthFirstSearch.java | 9 +++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/paladinus/PaladinusPlanner.java b/src/main/java/paladinus/PaladinusPlanner.java index 84a763c..63a1835 100644 --- a/src/main/java/paladinus/PaladinusPlanner.java +++ b/src/main/java/paladinus/PaladinusPlanner.java @@ -126,6 +126,24 @@ public static void main(String[] args) throws IOException, FileNotFoundException } } + /** + * Print some Garbage Collector stats. + */ + public void printMEMStats() { + // Print memory usage + // https://stackoverflow.com/questions/3571203/what-are-runtime-getruntime-totalmemory-and-freememory + // https://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html + + // System.gc(); // call GC explicitly to get more accurate memory usage + // Runtime.getRuntime().gc(); + // System.out.println("\nGarbage collection called before memory consumtion check"); + + + long memUsedOverall = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.out.println("\nTotal Memory (GB) = " + memUsedOverall / Math.pow(1024, 3) + "\n"); + } + + /** * Print some Garbage Collector stats. */ @@ -267,10 +285,10 @@ public Result runProblem() { System.out.println("\nResult: No policy found. Undecided."); } else { assert planFound == Result.EXPANDED_ALL; - System.out.println("\nResult: Search-space exapanded."); + System.out.println("\nResult: Search-space expanded."); } System.out.println(); - System.out.println("Time needed for preprocess (Parsing, PDBs, ...): " + timeUsedForPreprocessing / 1000.0 + " seconds."); + System.out.println("Time needed for preprocessing (parsing, PDBs, ...): " + timeUsedForPreprocessing / 1000.0 + " seconds."); System.out.println("Time needed for search: " + (timeUsedOverall - timeUsedForPreprocessing) / 1000.0 + " seconds."); System.out.println("Time needed: " + timeUsedOverall / 1000.0 + " seconds."); printGCStats(); @@ -339,7 +357,7 @@ public Result runProblemWithoutStats() { if(heuristic != null) search = new IterativeDepthFirstSearchPruning(problem, heuristic, Global.options.actionSelectionCriterion, Global.options.evaluationFunctionCriterion, Global.options.checkSolvedStates); break; - + case ITERATIVE_DFS_LEARNING: System.out.println("Algorithm: Iterative Depth-First Search Learning for FOND Planning"); if(heuristic != null) @@ -362,6 +380,10 @@ public Result runProblemWithoutStats() { } search.setTimeout(Global.options.timeout - timeUsedForPreprocessing); + printMEMStats(); + printGCStats(); + + // submit the search job to the thread pool ExecutorService service = Executors.newFixedThreadPool(1); Future futureResult = service.submit(search); try{ @@ -372,7 +394,8 @@ public Result runProblemWithoutStats() { } catch (InterruptedException e) { planFound = Result.TIMEOUT; e.printStackTrace(); - } catch (ExecutionException e) { + } catch (ExecutionException e) { // https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ExecutionException.html + // #TODO: shouldn't this go last? planFound = Result.OUT_OF_MEMORY; if(e.getCause() instanceof NullPointerException) planFound = Result.TIMEOUT; @@ -384,7 +407,9 @@ public Result runProblemWithoutStats() { } /* Stop measuring search time. */ timeUsedOverall = System.currentTimeMillis() - startTime; - System.out.println("\nTotal Memory (GB) = " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/ (1024.0 * 1024.0 * 1024.0)) + "\n"); + + printMEMStats(); + assert planFound != null; return planFound; } diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java index c924c27..76ee492 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java @@ -59,6 +59,8 @@ public Result run() { } protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { + long memUsed = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + if(unitaryBound) { this.POLICY_BOUND = 0; } else { @@ -90,7 +92,14 @@ protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { } else this.POLICY_BOUND = this.NEW_POLICY_BOUND; this.NEW_POLICY_BOUND = Double.POSITIVE_INFINITY; + + + memUsed = Math.max(memUsed, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); + } while (flag != SearchFlag.GOAL && this.POLICY_BOUND < Double.POSITIVE_INFINITY && flag != SearchFlag.TIMEOUT); + + System.out.println("\nMax total Memory (GB) = " + memUsed / Math.pow(1024, 3) + "\n"); + return flag; } From 4d74b824a539d42f43b1cbcc862586ffc5ab851a Mon Sep 17 00:00:00 2001 From: ssardina Date: Sun, 16 Apr 2023 09:07:25 +1000 Subject: [PATCH 2/7] track mem for DFS prunning --- .../dfs/iterative/IterativeDepthFirstSearchPruning.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java index f421f58..bf600bb 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java @@ -66,6 +66,8 @@ public Result run() { } protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { + long memUsed = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + if(unitaryBound) { this.POLICY_BOUND = 0; } else { @@ -99,7 +101,13 @@ protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { } else this.POLICY_BOUND = this.NEW_POLICY_BOUND; this.NEW_POLICY_BOUND = Double.POSITIVE_INFINITY; + + memUsed = Math.max(memUsed, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); + } while (flag != SearchFlag.GOAL && this.POLICY_BOUND < Double.POSITIVE_INFINITY && flag != SearchFlag.TIMEOUT); + + System.out.println("\nMax total Memory (GB) = " + memUsed / Math.pow(1024, 3) + "\n"); + return flag; } From df14ae21eee3a128f31f911c6702230f5aff2be3 Mon Sep 17 00:00:00 2001 From: ssardina Date: Mon, 17 Apr 2023 00:17:53 +1000 Subject: [PATCH 3/7] track memoru usage in DFS prunning --- src/main/java/paladinus/PaladinusPlanner.java | 3 - .../search/dfs/DepthFirstSearch.java | 12 +++ .../IterativeDepthFirstSearchPruning.java | 85 ++++++++++--------- 3 files changed, 56 insertions(+), 44 deletions(-) diff --git a/src/main/java/paladinus/PaladinusPlanner.java b/src/main/java/paladinus/PaladinusPlanner.java index 63a1835..0819b54 100644 --- a/src/main/java/paladinus/PaladinusPlanner.java +++ b/src/main/java/paladinus/PaladinusPlanner.java @@ -380,9 +380,6 @@ public Result runProblemWithoutStats() { } search.setTimeout(Global.options.timeout - timeUsedForPreprocessing); - printMEMStats(); - printGCStats(); - // submit the search job to the thread pool ExecutorService service = Executors.newFixedThreadPool(1); Future futureResult = service.submit(search); diff --git a/src/main/java/paladinus/search/dfs/DepthFirstSearch.java b/src/main/java/paladinus/search/dfs/DepthFirstSearch.java index 83896c8..70d1c38 100644 --- a/src/main/java/paladinus/search/dfs/DepthFirstSearch.java +++ b/src/main/java/paladinus/search/dfs/DepthFirstSearch.java @@ -54,6 +54,10 @@ public class DepthFirstSearch extends HeuristicSearch { protected double estimatedValueBestConnectorFromInitialState = 0; protected int NUMBER_ITERATIONS = 0; + + // to track memory usage + protected float memoryUsed = 0; + protected long lastMemTaken; protected Map stateNodeMapHValue = new HashMap(); @@ -75,6 +79,14 @@ public DepthFirstSearch(Problem problem, Heuristic heuristic) { super(problem, heuristic); } + protected void updateMem() { + if (System.currentTimeMillis() - lastMemTaken > 1000) { + System.out.println("Memory check"); + this.memoryUsed = Math.max(this.memoryUsed, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); + lastMemTaken = System.currentTimeMillis(); + } + } + @Override public void doIteration() {} diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java index bf600bb..c589d31 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java @@ -13,17 +13,17 @@ import paladinus.util.Pair; /** - * + * * An iterative (pruning) depth-first search algorithm for FOND Planning. - * + * * @author Ramon Fraga Pereira * */ public class IterativeDepthFirstSearchPruning extends DepthFirstSearch { - + protected double POLICY_SIZE = 0; protected double NEW_POLICY_BOUND = 0; - + private boolean checkSolvedStates = false; public IterativeDepthFirstSearchPruning(Problem problem, Heuristic heuristic, String strategies, String criterion, String checkSolved) { @@ -33,7 +33,7 @@ public IterativeDepthFirstSearchPruning(Problem problem, Heuristic heuristic, St System.out.println("Check Solveds: TRUE"); } } - + @Override public Result run() { /* Start measuring search time. */ @@ -48,81 +48,83 @@ public Result run() { /* Finish measuring search time. */ endtime = System.currentTimeMillis(); - + System.out.println("\n# Closed-Solved Nodes = " + this.closedSolvedNodes.size()); System.out.println("\n# Closed-Non-Promising Nodes = " + this.closedDeadEndsNodes.size()); - + + System.out.println("\nMax total Memory (GB) = " + this.memoryUsed / Math.pow(1024, 3) + "\n"); + + if (DEBUG) dumpStateSpace(this.NUMBER_ITERATIONS); if(timeout()) return Result.TIMEOUT; - + if (flag == SearchFlag.GOAL) { return Result.PROVEN; } else if (flag == SearchFlag.DEAD_END || flag == SearchFlag.NO_POLICY) { return Result.DISPROVEN; } else return Result.TIMEOUT; } - - protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { - long memUsed = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { if(unitaryBound) { - this.POLICY_BOUND = 0; + this.POLICY_BOUND = 0; } else { this.POLICY_BOUND = node.getHeuristic(); if(this.POLICY_BOUND == Double.POSITIVE_INFINITY) return SearchFlag.NO_POLICY; } SearchFlag flag = SearchFlag.NO_POLICY; - + this.NEW_POLICY_BOUND = Double.POSITIVE_INFINITY; - + System.out.println("\n> Bound Initial: " + this.POLICY_BOUND); System.out.println(); do { - System.out.println("> Bound: " + this.POLICY_BOUND); + System.out.println("> Bounds: " + this.POLICY_BOUND); this.POLICY_SIZE = 0d; - + this.dumpingCounterStateSpace = 0; this.NUMBER_ITERATIONS++; Set closedSolved = new HashSet<>(); this.closedVisitedNodes.clear(); this.closedDeadEndsNodes.clear(); - + Pair> resultSearch = doIterativeSearch(node, closedSolved, this.POLICY_SIZE, this.POLICY_BOUND); flag = resultSearch.first; this.closedSolvedNodes = resultSearch.second; - + if(unitaryBound) { - this.POLICY_BOUND++; + this.POLICY_BOUND++; } else this.POLICY_BOUND = this.NEW_POLICY_BOUND; - + this.NEW_POLICY_BOUND = Double.POSITIVE_INFINITY; - memUsed = Math.max(memUsed, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); + this.updateMem(); } while (flag != SearchFlag.GOAL && this.POLICY_BOUND < Double.POSITIVE_INFINITY && flag != SearchFlag.TIMEOUT); - System.out.println("\nMax total Memory (GB) = " + memUsed / Math.pow(1024, 3) + "\n"); - return flag; } - + protected Pair> doIterativeSearch(SearchNode node, Set closedSolved, double policySize, double policyBound) { if (DEBUG) dumpStateSpace(this.NUMBER_ITERATIONS); - + + this.updateMem(); + + if(RECURSION_COUNTER >= Integer.MAX_VALUE) return new Pair>(SearchFlag.DEAD_END, closedSolved); - + if(timeout()) return new Pair>(SearchFlag.TIMEOUT, null); RECURSION_COUNTER++; - + if(node.isGoalNode() || closedSolved.contains(node)) { closedSolved.addAll(this.closedVisitedNodes); return new Pair>(SearchFlag.GOAL, closedSolved); @@ -130,35 +132,36 @@ protected Pair> doIterativeSearch(SearchNode node, S return new Pair>(SearchFlag.DEAD_END, closedSolved); } else if (this.closedVisitedNodes.contains(node)) return new Pair>(SearchFlag.VISITED, closedSolved); - + this.closedVisitedNodes.add(node); - + PriorityQueue connectors = this.getNodeConnectors(node); NODE_EXPANSIONS++; - + boolean allConnectorsDeadEnds = true; while(!connectors.isEmpty()) { SearchConnector c = connectors.poll(); - + if(policySize + 1 + c.getEvaluationFunctionAccordingToCriterion() > policyBound && closedSolved.size() == 0) { if(policySize + 1 + c.getEvaluationFunctionAccordingToCriterion() < this.NEW_POLICY_BOUND ) - this.NEW_POLICY_BOUND = policySize + 1 + c.getEvaluationFunctionAccordingToCriterion(); + this.NEW_POLICY_BOUND = policySize + 1 + c.getEvaluationFunctionAccordingToCriterion(); } else if(policySize + 1 > policyBound) { if(policySize + 1 < this.NEW_POLICY_BOUND) this.NEW_POLICY_BOUND = policySize + 1; - } else { + } else { Set pathsFound = new HashSet<>(); - + boolean newGoalPathFound = true; - + boolean connectorDeadEnd = false; - + Set copyClosedSolved = new HashSet<>(closedSolved); - + while(newGoalPathFound == true) { + newGoalPathFound = false; Set findingGoalPath = new HashSet<>(); - + for(SearchNode s: c.getChildren()) { if(!pathsFound.contains(s)) findingGoalPath.add(s); @@ -167,7 +170,7 @@ protected Pair> doIterativeSearch(SearchNode node, S Pair> resultSearch = doIterativeSearch(s, copyClosedSolved, policySize+1, policyBound); SearchFlag flag = resultSearch.first; copyClosedSolved = new HashSet(resultSearch.second); - + if(flag == SearchFlag.DEAD_END) { newGoalPathFound = false; connectorDeadEnd = true; @@ -193,11 +196,11 @@ protected Pair> doIterativeSearch(SearchNode node, S this.closedDeadEndsNodes.add(node); return new Pair>(SearchFlag.DEAD_END, closedSolved); } - + this.closedVisitedNodes.remove(node); return new Pair>(SearchFlag.VISITED, closedSolved); } - + @Override public void printStats(boolean simulatePlan) { System.out.println("# Number Iterations = " + this.NUMBER_ITERATIONS); From fafe69462dd2e8492d48c800b8de1dd35c7c509b Mon Sep 17 00:00:00 2001 From: ssardina Date: Thu, 20 Apr 2023 11:51:52 +1000 Subject: [PATCH 4/7] improve shell script to restrict max heap --- paladinus | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/paladinus b/paladinus index 320c3a7..762e725 100755 --- a/paladinus +++ b/paladinus @@ -3,4 +3,12 @@ DIR=$(dirname "$0") JAR=$DIR/target/paladinus-1.1-jar-with-dependencies.jar -java -jar $JAR -translatorPath $DIR/translator-fond/translate.py "$@" +# restrict the max heap size that can be used by the JVM +# MAX_HEAP=-Xmx512m +MAX_HEAP="" + +# if one wants to use JCMD https://www.baeldung.com/running-jvm-diagnose +JCMD="-XX:NativeMemoryTracking=summary" +JCMD="" + +java $MAX_HEAP $JCMD -jar $JAR -translatorPath $DIR/translator-fond/translate.py "$@" From 40a2c6fa7ff5abb84456c573aeed6c68403cdf77 Mon Sep 17 00:00:00 2001 From: ssardina Date: Thu, 20 Apr 2023 11:52:11 +1000 Subject: [PATCH 5/7] better report of memory usage --- src/main/java/paladinus/PaladinusPlanner.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/paladinus/PaladinusPlanner.java b/src/main/java/paladinus/PaladinusPlanner.java index 0819b54..4bbfbdf 100644 --- a/src/main/java/paladinus/PaladinusPlanner.java +++ b/src/main/java/paladinus/PaladinusPlanner.java @@ -94,6 +94,9 @@ public class PaladinusPlanner { public PaladinusPlanner(String[] args) throws FileNotFoundException, IOException { new Global().initialize(); initialize(args); + + // do a frist memory report + printMEMStats(); } // public PaladinusPlanner() {} @@ -139,8 +142,22 @@ public void printMEMStats() { // System.out.println("\nGarbage collection called before memory consumtion check"); - long memUsedOverall = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - System.out.println("\nTotal Memory (GB) = " + memUsedOverall / Math.pow(1024, 3) + "\n"); + Runtime r = Runtime.getRuntime(); + double gb = Math.pow(1024, 3); + + double maxMemory = r.maxMemory() / gb; // max memory it can ever use, limit + double totalMemory = r.totalMemory() / gb; // current reserved memory (less than max) + double freeMemory = r.freeMemory() / gb; // free memory that can be allocated (less than total) + double usedMemory = totalMemory - freeMemory; // current memory been used (from totalMemory) + + System.out.println("=============================="); + System.out.println("MEMORY REPORTING (all in GB)"); + System.out.println("=============================="); + System.out.println("Max memory: " + maxMemory); + System.out.println("Total reserved memory: " + totalMemory); + System.out.println("Free memory: " + freeMemory); + System.out.println("Used memory: " + usedMemory); + System.out.println("=============================="); } From 9a9183b6bdddca9a59f522c018640aaca906cb25 Mon Sep 17 00:00:00 2001 From: ssardina Date: Thu, 20 Apr 2023 11:52:27 +1000 Subject: [PATCH 6/7] add memory probing in debug mode --- .../iterative/IterativeDepthFirstSearch.java | 4 +++- .../IterativeDepthFirstSearchLearning.java | 5 ++++- .../IterativeDepthFirstSearchPruning.java | 17 ++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java index 76ee492..22481dd 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearch.java @@ -104,8 +104,10 @@ protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { } protected Pair> doIterativeSearch(SearchNode node, Set closedSolved, double policySize, double policyBound) { - if (DEBUG) + if (DEBUG) { dumpStateSpace(this.NUMBER_ITERATIONS); + this.updateMem(); // probe memory consumption + } if(timeout()) return new Pair>(SearchFlag.TIMEOUT, null); diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchLearning.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchLearning.java index 15c21dd..a09a8b8 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchLearning.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchLearning.java @@ -95,8 +95,11 @@ protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { } protected Pair> doIterativeSearch(SearchNode node, Set closedSolved, double policySize, double policyBound) { - if (DEBUG) + if (DEBUG) { dumpStateSpace(); + this.updateMem(); // probe memory consumption + } + if(timeout()) return new Pair>(SearchFlag.TIMEOUT, null); diff --git a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java index c589d31..25359e5 100644 --- a/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java +++ b/src/main/java/paladinus/search/dfs/iterative/IterativeDepthFirstSearchPruning.java @@ -52,11 +52,10 @@ public Result run() { System.out.println("\n# Closed-Solved Nodes = " + this.closedSolvedNodes.size()); System.out.println("\n# Closed-Non-Promising Nodes = " + this.closedDeadEndsNodes.size()); - System.out.println("\nMax total Memory (GB) = " + this.memoryUsed / Math.pow(1024, 3) + "\n"); - - - if (DEBUG) + if (DEBUG) { + System.out.println("\nMax total Memory probed (GB) = " + this.memoryUsed / Math.pow(1024, 3) + "\n"); dumpStateSpace(this.NUMBER_ITERATIONS); + } if(timeout()) return Result.TIMEOUT; @@ -103,19 +102,18 @@ protected SearchFlag doIterativeSearch(Boolean unitaryBound, SearchNode node) { this.NEW_POLICY_BOUND = Double.POSITIVE_INFINITY; - this.updateMem(); - } while (flag != SearchFlag.GOAL && this.POLICY_BOUND < Double.POSITIVE_INFINITY && flag != SearchFlag.TIMEOUT); return flag; } protected Pair> doIterativeSearch(SearchNode node, Set closedSolved, double policySize, double policyBound) { - if (DEBUG) + if (DEBUG) { dumpStateSpace(this.NUMBER_ITERATIONS); + this.updateMem(); // probe memory consumption + } - this.updateMem(); - + if(RECURSION_COUNTER >= Integer.MAX_VALUE) return new Pair>(SearchFlag.DEAD_END, closedSolved); @@ -167,6 +165,7 @@ protected Pair> doIterativeSearch(SearchNode node, S findingGoalPath.add(s); } for(SearchNode s: findingGoalPath) { + // recursive call! Pair> resultSearch = doIterativeSearch(s, copyClosedSolved, policySize+1, policyBound); SearchFlag flag = resultSearch.first; copyClosedSolved = new HashSet(resultSearch.second); From df5552dfbfeec9e36a3582b2769a898afd1580aa Mon Sep 17 00:00:00 2001 From: ssardina Date: Thu, 20 Apr 2023 11:52:52 +1000 Subject: [PATCH 7/7] remove printout when probing memory --- src/main/java/paladinus/search/dfs/DepthFirstSearch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/paladinus/search/dfs/DepthFirstSearch.java b/src/main/java/paladinus/search/dfs/DepthFirstSearch.java index 70d1c38..5f47d40 100644 --- a/src/main/java/paladinus/search/dfs/DepthFirstSearch.java +++ b/src/main/java/paladinus/search/dfs/DepthFirstSearch.java @@ -79,9 +79,9 @@ public DepthFirstSearch(Problem problem, Heuristic heuristic) { super(problem, heuristic); } + // probes current memory consumption and stores it if greater than previous probe protected void updateMem() { if (System.currentTimeMillis() - lastMemTaken > 1000) { - System.out.println("Memory check"); this.memoryUsed = Math.max(this.memoryUsed, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); lastMemTaken = System.currentTimeMillis(); }