0

I have a graph with about 6000 nodes (pedigree). The program should determine all ways between two given nodes (relationship). Depending on the position of the start and destination nodes, the number of paths to be searched can be very large. Now I want to monitor the free heap so that I can adjust the search strategy depending on the size still available. How can I determine the size of the free heap?

Translated with www.DeepL.com/Translator (free version)

trincot
  • 317,000
  • 35
  • 244
  • 286
  • What concrete problem you solve? Why you need to determine all ways? Do you know Dijkstra's (and so on) algorithms? – Mikhail Ionkin Oct 11 '20 at 14:32
  • 1
    I assume that [this thread](https://stackoverflow.com/questions/12807797/java-get-available-memory) already describes all your options. However, I'm quite skeptical about the whole approach altogether, because there doesn't seem to be any reliable way to determine how much memory can be freed with a garbage collection, without actually doing the garbage collection pass, and this is something that is not under your control. I'd suggest to search for more reliable ways to estimate how much resources you have used. Even better: redesign your algorithm to work in roughly constant space. – Andrey Tyukin Oct 11 '20 at 15:07
  • 1
    I don't think there's any Scala-specific angle to this question. It's a JVM question. – Seth Tisue Oct 12 '20 at 19:19

1 Answers1

0

Assuming since you included this post in the [scala] tag and you mentioned this is a Scala application, you are running in the JVM. If you just need simple monitoring, you would just need JVisualVM or the Visual Flight Recorder as you are running your JVM. I personally use JVisualVM. Works great. I believe the flight recorder will record it's heap use over time so you can do a review and maybe wire it up in a performance test.

Below is an image of the flight recorder.

Flight Recorder

Below is an image of JVisualVM.

JVisualVM

Daniel Hinojosa
  • 972
  • 5
  • 9