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

OutOfMemoryError during Calculation using API #14

Open
slothyoung opened this issue Jul 29, 2018 · 3 comments
Open

OutOfMemoryError during Calculation using API #14

slothyoung opened this issue Jul 29, 2018 · 3 comments
Labels

Comments

@slothyoung
Copy link

I am currently working with the OpenLCA API in Eclipse. But with some Processes/Product Systems, I encounter an OutOfMemoryError during the Calculation of a ProductSystem.

The following is the Print-Stack:
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
at org.apache.commons.math3.linear.Array2DRowRealMatrix.copyOut(Array2DRowRealMatrix.java:528)
at org.apache.commons.math3.linear.Array2DRowRealMatrix.getData(Array2DRowRealMatrix.java:253)
at org.apache.commons.math3.linear.LUDecomposition.(LUDecomposition.java:92)
at org.apache.commons.math3.linear.LUDecomposition.(LUDecomposition.java:75)
at org.openlca.core.matrix.solvers.JavaSolver.solve(JavaSolver.java:23)
at org.openlca.core.math.LcaCalculator.calculateContributions(LcaCalculator.java:73)

The line causing the error is the following:
ContributionResult result = calculator.calculateContributions(setup);

I was monitoring my RAM Usage (8GB Machine) and RAM was not required more than 80% shortly before the crash. I do not have this behavior with every calculation, but with many. In OpenLCA itself, the calculations finishes without problems.

The question I ask myself now is, how to remedy this Error?

@msrocka
Copy link
Member

msrocka commented Aug 13, 2018

You can increase the heap space for your Python script in Eclipse under Run > Run Configuration. There you can set the max. heap space parameter for the JVM via the -Xmx flag, e.g. -Xmx2048M would set it to 2048 megabytes. See also this answer on Stackoverflow.

Also, you could use the native library and the DenseSolver for faster calculations (see line 113 in the example script).

@slothyoung
Copy link
Author

Thanks for the reply!

I am afraid to have not explained my case well enough. I am not trying to run Python Scripts inside OpenLCA, but rather use the APIs in Eclipse, basically following this tutorial:
https://github.com/GreenDelta/openlca-python-tutorial/blob/master/ide_setup.md

However, I do not use Jython, but Java directly. And in this situation, the Exceptions are thrown. I already raised the Maximum Heap Size, but that unfortunately did not help.
The DenseSolver did not work for me either because i get an UnsatisfiedLinkError. Maybe there is something that I am missing.

@msrocka
Copy link
Member

msrocka commented Aug 15, 2018

Maybe you just need to assign more memory; what happens if you set it to 6G? (for an ecoinvent 3.4 system, openLCA currently needs ~3.5 GB of memory.)

Regarding the link error: as in the Python script, you first need to load the native library before you can use it. So, before you use the dense solver, you would load the library like this:

NativeLibrary.loadFromDir(new File("path/to/native/lib/folder"))

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

No branches or pull requests

2 participants