Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leakage when check for simple cycles #1221

Open
dantemessy opened this issue Apr 17, 2024 · 1 comment
Open

Memory leakage when check for simple cycles #1221

dantemessy opened this issue Apr 17, 2024 · 1 comment

Comments

@dantemessy
Copy link

 * JGraphT version: 1.4.0
 * Java version (java -version)/platform:  17.0.4

Issue
We're utilizing JGraphT to construct flows, and we check for flow cycles using the findSimpleCycles method. we faced an issue with a specific flow, the code got stuck when cycleFinder.findSimpleCycles() was triggered. This led to a memory leak and froze the entire application.

Steps to reproduce (small coding example)

The flow attached below as a dot file.
final_flow.zip

 private static List<List<String>> getOpenLoops(Graph<String, DefaultEdge> mergedGraph) {
        JohnsonSimpleCycles<String, DefaultEdge> cycleFinder = new JohnsonSimpleCycles<>(mergedGraph);
        List<List<String>> foundedCycles = cycleFinder.findSimpleCycles();
        return foundedCycles;
    }

Expected behaviour
It should return a list of graph cycles.

@dantemessy
Copy link
Author

Quick updates: It looks like the main issue here is the huge size of the cycles found, as I observed in the app heap dump.
Screenshot from 2024-05-16 11-27-40

This mostly happened because there were no limits on the number of cycles that could be found(which is 7,533,137 in my case). To address this, we modified the source code to set a maximum limit on the number of cycles that can be found and interrupt the process once this limit is reached.

This solved our issue, but I am not sure if this is the best approach for JGraphT as a free library. If this solution works for you as well, I can create a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant