Skip to content

Instantly share code, notes, and snippets.

@akosiaris
Last active August 19, 2024 22:21
Show Gist options
  • Save akosiaris/a643e4cdd389fbf0bb81468547ade07e to your computer and use it in GitHub Desktop.
Save akosiaris/a643e4cdd389fbf0bb81468547ade07e to your computer and use it in GitHub Desktop.
Crude memory accounting patch for endless-ships/parser.clj
--- a/src/clj/endless_ships/parser.clj
+++ b/src/clj/endless_ships/parser.clj
@@ -50,8 +50,12 @@
(->> files
(mapcat (fn [file]
(let [filename (.getName file)
- _ (println (format "parsing %s..." filename))
- objects (-> file slurp (str "\n") parse)]
+ filesize (.length file)
+ usedMem (float (/ (- (-> (java.lang.Runtime/getRuntime) (.totalMemory)) (-> (java.lang.Runtime/getRuntime) (.freeMemory))) 1024))
+ _ (println (format "parsing: %s. Size: %s. Used memory before parse: %s" filename filesize usedMem))
+ objects (-> file slurp (str "\n") parse)
+ usedMem2 (float (/ (- (-> (java.lang.Runtime/getRuntime) (.totalMemory)) (-> (java.lang.Runtime/getRuntime) (.freeMemory))) 1024))
+ _ (println (format "Used memory after parse: %s" usedMem2))]
(map #(assoc-in % [2 "file"] filename) objects))))
doall)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment