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

Bug: OutOfMemory when using Maven and identation size 4 #10129

Closed
cwichoski opened this issue Jun 21, 2024 Discussed in #10111 · 4 comments · Fixed by #10143
Closed

Bug: OutOfMemory when using Maven and identation size 4 #10129

cwichoski opened this issue Jun 21, 2024 Discussed in #10111 · 4 comments · Fixed by #10143
Labels
area: bug 🐛 Something isn't working $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ generator: internal $200 https://www.jhipster.tech/bug-bounties/

Comments

@cwichoski
Copy link

Discussed in #10111

Originally posted by cwichoski June 19, 2024
Hi

I build and run jhipster and got OutOfMemory error, then changed to increase memory to 4Gb with follow command:

jhipster-lite$ java -Xmx4096m -Xms4096m -jar target/*.jar

but still getting OutOfMemory when try to generate the code.

Here is the partial exception

java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.Arrays.copyOf(Arrays.java:3595)
	at java.base/java.lang.StringLatin1.replace(StringLatin1.java:345)
	at java.base/java.lang.String.replace(String.java:3100)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.maven.MavenCommandHandler.applyIndentation(MavenCommandHandler.java:447)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.maven.MavenCommandHandler.writePom(MavenCommandHandler.java:437)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.maven.MavenCommandHandler.addDependencyTo(MavenCommandHandler.java:279)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.maven.MavenCommandHandler.handle(MavenCommandHandler.java:268)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.FileSystemJavaBuildCommandsHandler.handle(FileSystemJavaBuildCommandsHandler.java:76)
	at tech.jhipster.lite.module.infrastructure.secondary.javadependency.FileSystemJavaBuildCommandsHandler.lambda$handle$0(FileSystemJavaBuildCommandsHandler.java:51)

I'm using:

branch main
JDK 21.0.3-tem
maven 3.9.7
nodejs 18.16.0

Any idea?

@cwichoski
Copy link
Author

I found a solution and going to provide a pull request

@cwichoski cwichoski changed the title OutOfMemory when using Maven and identation size 4 Bug: OutOfMemory when using Maven and identation size 4 Jun 21, 2024
cwichoski added a commit to cwichoski/jhipster-lite that referenced this issue Jun 24, 2024
If you add many modules and change the indentation size to 4, when newer dependencies are added to pom.xml the current indentation algorithm causes a loop that increase memory exponentially by each dependency, to avoid this we changed to use a XML formatter.

fix jhipster#10129
@cwichoski
Copy link
Author

I pushed a solution here [1] but I'm with difficult to understand what jacoco needs me to test more, as it's my first time using a project with jacoco and with 100% of code coverage needed, anyone have a clue what more I need to test?

[INFO] Analyzed bundle 'jhlite' with 815 classes
[WARNING] Rule violated for class tech.jhipster.lite.module.infrastructure.secondary.javadependency.maven.MavenCommandHandler: lines covered ratio is 0.99, but expected minimum is 1.00

[1] main...cwichoski:jhipster-lite:bug10129

@renanfranca
Copy link
Contributor

anyone have a clue what more I need to test?

@cwichoski : After running ./mvnw clean verify, go to the target/site/jacoco folder and open the index.html file, which shows the coverage for every package. Navigate to your class and see what is missing to test.

cwichoski added a commit to cwichoski/jhipster-lite that referenced this issue Jun 24, 2024
If you add many modules and change the indentation size to 4, when newer dependencies are added to pom.xml the current indentation algorithm causes a loop that increase memory exponentially by each dependency, to avoid this we changed to use a XML formatter.

fix jhipster#10129
@pascalgrimaud pascalgrimaud added $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ $200 https://www.jhipster.tech/bug-bounties/ labels Jun 25, 2024
@pascalgrimaud
Copy link
Member

I'm adding a bounty on this important ticket
as @murdos and @cwichoski worked a lot on this, you can share the bounty plz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bug 🐛 Something isn't working $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ generator: internal $200 https://www.jhipster.tech/bug-bounties/
Projects
None yet
3 participants