Skip to content

Android: Throw an OutOfMemoryError when creating a database #5292

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

Closed
LqL670 opened this issue Feb 28, 2021 · 6 comments
Closed

Android: Throw an OutOfMemoryError when creating a database #5292

LqL670 opened this issue Feb 28, 2021 · 6 comments
Labels
question Further information is requested

Comments

@LqL670
Copy link

LqL670 commented Feb 28, 2021

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at javac_extend.com.sun.tools.javac.code.Scope$ScopeImpl.dupUnshared(Scope.java:377)
	at javac_extend.com.sun.tools.javac.comp.MemberEnter.initEnv(MemberEnter.java:425)
	at javac_extend.com.sun.tools.javac.comp.MemberEnter.getInitEnv(MemberEnter.java:454)
	at javac_extend.com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:295)
	at javac_extend.com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:993)
	at javac_extend.com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:164)
	at javac_extend.com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:176)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$MembersPhase.finishClass(TypeEnter.java:1081)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:1025)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:292)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$AbstractMembersPhase.doCompleteEnvs(TypeEnter.java:935)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:261)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:276)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:276)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:276)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:276)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:276)
	at javac_extend.com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:208)
	at javac_extend.com.sun.tools.javac.code.Symbol.complete(Symbol.java:685)
	at javac_extend.com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1413)
	at javac_extend.com.sun.tools.javac.comp.Enter.complete(Enter.java:584)
	at javac_extend.com.sun.tools.javac.comp.Enter.main(Enter.java:561)
	at javac_extend.com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1069)
	at com.semmle.extractor.java.JavaExtractor.runExtractor(JavaExtractor.java:289)
	at com.semmle.extractor.java.JavaExtractor.runExtractor(JavaExtractor.java:223)
	at com.semmle.extractor.java.JavaExtractor.main(JavaExtractor.java:487)
[Process Builder] Spawned process exited abnormally (code 1; tried to run: [/Users/aaa/work/codeql-home/codeql/java/tools/macos/jdk-extractor-java/bin/java, -Dfile.encoding=UTF-8, -Xmx1024M, -Xms256M, -classpath, /Users/aaa/work/codeql-home/codeql/java/tools/semmle-extractor-java.jar, com.semmle.extractor.java.JavaExtractor, --jdk-version, -1, --javac-args, @@@/Users/aaa/work/a/b/java-databse/log/ext/javac-5.args]
[ODASA Javac] Non-zero exit code 1 from ODASA javac builder
> Task :app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac took 45592ms
> Task :app:compileDebugJavaWithJavac FAILED
@LqL670 LqL670 added the question Further information is requested label Feb 28, 2021
@LqL670
Copy link
Author

LqL670 commented Feb 28, 2021

I think it may be that -Xmx1024M is set too small, how can I set a larger value? @aschackmull

@aeisenberg
Copy link
Contributor

A little surprised that the default is too small for you. It is possible to explicitly set options directly sent to the underlying JVM. You can do this by using a -J= prefix. To set 2GB for the heap, you can:

codeql create database -J=-Xmx2G -J=-Xms1G ...`

@LqL670
Copy link
Author

LqL670 commented Feb 28, 2021

It doesn't work.I found the above hard-coded -Xmx1024M code. @aeisenberg
com.semmle.extractor.java.Utils.invokeOdasaJavac in codeql-java-agent.jar

ArrayList cmdLine = new ArrayList(Arrays.asList(new String[]{runExtractorJDK + File.separator + "bin" + File.separator + executable, "-Dfile.encoding=UTF-8", "-Xmx1024M", "-Xms256M"}));

@LqL670
Copy link
Author

LqL670 commented Feb 28, 2021

Analyzing the log, I think the problem is that the hard-coded value here is too small, what do you think?

@aeisenberg
Copy link
Contributor

That seems like a plausible explanation. Two things I can recommend trying:

  1. Try explicitly setting a compile command, like codeql database create --command="javac -Xmx2G ..." ...
  2. You can specify extra JVM arguments in the SEMMLE_JAVA_EXTRACTOR_JVM_ARGS environment variable.

If neither of those help, I'll get someone with more direct experience on the extractor to weigh in.

@LqL670
Copy link
Author

LqL670 commented Mar 1, 2021

Thanks for your answer.I specify extra JVM arguments in the SEMMLE_JAVA_EXTRACTOR_JVM_ARGS,like export SEMMLE_JAVA_EXTRACTOR_JVM_ARGS='-Xmx4g -Xms512m'Finally, there was no problem.

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

No branches or pull requests

2 participants