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

Dart - openapi-generator-cli-5.3.0 - java.lang.OutOfMemoryError: Java heap space #11195

Open
amdderik opened this issue Dec 9, 2021 · 3 comments

Comments

@amdderik
Copy link

amdderik commented Dec 9, 2021

Version:
openapi-generator-cli-5.3.0 error also occurs on 5.1.0 and 4.3.1
Environment:
Windows 10 Enterprise Edition 1909
At the time of executing the command, I have 44 GB of free memory, after executing java will consume all of the remaining memory.

Computer:
6 core i7 processor with 64 GB RAM

Command:
java -Xmx64G -jar ./openapi-generator-cli-5.3.0.jar generate -i http://localhost:5000/swagger/v1/swagger.json -g dart -o ../cafdexgo-server -c ./openapi-gen-config.yaml

I have tried -Xmx84G and made the swap space on my OS 64GB, still failed
I have tried -Xmx48G, still failed
I have tried -Xmx24G, still failed

The openapi generator has worked great for my project for the last year, however it has been running out of memory the more models I add to the serverside project, so I keep increasing the -Xmx parameter, however with the last model that I added I am not able to get it to generate successfully, it just keeps throwing the out of memory exception. My project currently has 223 models, so it is getting pretty big. The more models I add to the project the longer the open api generator takes to complete, if I remove my last model so it will successfully generate it takes about 15 minutes to complete and it is all after the ModelUtils line in the console

Do you have any suggestions on how I can get open api generator to work?
I am really stuck at this point since this seems to be one of the only methods to generate dart code from swagger.

[main] WARN o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (text/plain)
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.fasterxml.jackson.core.util.TextBuffer.carr(TextBuffer.java:886)
at com.fasterxml.jackson.core.util.TextBuffer.expand(TextBuffer.java:847)
at com.fasterxml.jackson.core.util.TextBuffer.append(TextBuffer.java:612)
at com.fasterxml.jackson.core.io.SegmentedStringWriter.write(SegmentedStringWriter.java:58)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeRaw(WriterBasedJsonGenerator.java:598)
at com.fasterxml.jackson.core.util.DefaultIndenter.writeIndentation(DefaultIndenter.java:91)
at com.fasterxml.jackson.core.util.DefaultPrettyPrinter.beforeObjectEntries(DefaultPrettyPrinter.java:288)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writePPFieldName(WriterBasedJsonGenerator.java:350)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator._writeFieldName(WriterBasedJsonGenerator.java:169)
at com.fasterxml.jackson.core.json.WriterBasedJsonGenerator.writeFieldName(WriterBasedJsonGenerator.java:152)
at com.fasterxml.jackson.databind.ser.std.StdKeySerializers$StringKeySerializer.serialize(StdKeySerializers.java:266)
at com.fasterxml.jackson.databind.ser.std.StdKeySerializers$Dynamic.serialize(StdKeySerializers.java:228)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:781)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:252)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:213)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:22)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:782)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:639)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:33)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:252)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:213)

@wing328 wing328 transferred this issue from OpenAPITools/openapi-generator-cli Dec 29, 2021
@kuhnroyal
Copy link
Contributor

You probably have some infinite loop map construct in your schema.

@kuhnroyal
Copy link
Contributor

@amdderik Did you find the cause? Can this be closed?

@Dakado
Copy link

Dakado commented Sep 26, 2022

I have the same problem but on version 6.0.0 and 6.2.0 trying to build angular code. Entities are all generated just fine, but services always crash on this error. I have tried to specify only 1 service to be generated which had 1 simple rest method, returning just string and it crashed as well.

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

3 participants