OpenAPITools / OpenAPITools/openapi-generator

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

Open
#11,195 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported command with the supplied Swagger URL, configuration file, Dart generator, and model count. Inspect the ModelUtils warning and the Jackson stack trace to identify where generation exhausts the heap; done means the project completes generation without the Java heap-space error.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.