karin
karin

Reputation: 43

java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"’ for a file of more than 4GB

Using this tool, https://github.com/citygml4j/citygml-tools, which is called to-cityjson. I want to convert a cityGML file to a cityJSON file. The file is 4.36 GB, but i get the following error:

java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread main or

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at jdk.internal.reflect.GeneratedConstructorAccessor183.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.sun.xml.bind.v2.ClassFactory.create0(ClassFactory.java:102)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.createInstance(ClassBeanInfoImpl.java:255)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.createInstance(UnmarshallingContext.java:672)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.startElement(StructureLoader.java:158)
    at com.sun.xml.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:30)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$IntercepterLoader.startElement(ElementBeanInfoImpl.java:223)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:547)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:526)
    at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:45)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:216)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:150)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:385)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:356)
    at org.citygml4j.builder.jaxb.xml.io.reader.JAXBSimpleReader.nextFeature(JAXBSimpleReader.java:133)
    at org.citygml4j.tools.command.ToCityJSONCommand.execute(ToCityJSONCommand.java:133)
    at org.citygml4j.tools.CityGMLTools.handleParseResult(CityGMLTools.java:102)
    at org.citygml4j.tools.CityGMLTools.handleParseResult(CityGMLTools.java:35)
    at picocli.CommandLine.parseWithHandlers(CommandLine.java:1526)
    at org.citygml4j.tools.CityGMLTools.main(CityGMLTools.java:44)

I found one solution, which would be to use java -Xmx15G, but i don't know how to implement it.

Upvotes: 3

Views: 31326

Answers (4)

Arquímedes-X9000
Arquímedes-X9000

Reputation: 11

Buddy Another option if you are using eclipse is the following.

This worked for me, I hope it helps you (click over here).

Upvotes: 0

Dr Phil
Dr Phil

Reputation: 880

You can try a brute Force approach and assign a very large healthy space

Grep for the line

 defaultJvmOpts = ['-Xms1G'] 

only 1 GiB of heap space

Also make sure you are using a 64 bit Java and have enough ram

Upvotes: 0

Karol Dowbecki
Karol Dowbecki

Reputation: 44980

You can use JAVA_OPTS or CITYGML_TOOLS_OPTS environment variable which is read by citygml-tools executable. Or you can modify the DEFAULT_JVM_OPTS option in the citygml-tools code:

# Add default JVM options here. You can also use JAVA_OPTS and CITYGML_TOOLS_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xms1G"'

If you are using Linux you can set in the terminal:

export JAVA_OPTS="-Xmx15G"
citygml-tools <file>

Upvotes: 2

Danyal Sandeelo
Danyal Sandeelo

Reputation: 12401

java -Xmx6144M -d64

Go to command line and execute this command, it will set it to 64 GB

Source: Increase heap size in Java

Upvotes: 1

Related Questions