java.lang.OutOfMemoryError: Java heap space

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Where are problems uploading big files to fedora using fedora-client v0.7 Test to reproduce bug: @Test public void addLargeStreamToFedora() throws IOException, FedoraClientException { FedoraCredentials fedoraCredentials = new FedoraCredentials("http://localhost:8085/fedora", "fedoraAdmin", "<password>"); FedoraClient fedoraClient = new FedoraClient(fedoraCredentials); AddDatastream addStream = new AddDatastream("test:atest1", "MAIN"); addStream.mimeType("application/pdf"); addStream.controlGroup("M"); addStream.dsLabel("ds_label_1"); Path filePath = Paths.get("<path to large file>"); InputStream is = Files.newInputStream(filePath); addStream.content(is); new Ingest("test:atest1").ownerId("test").execute(fedoraClient); addStream.execute(fedoraClient); //java.lang.OutOfMemoryError: Java heap space } stack trace: addLargeStream(...FedoraRepositoryIT) Time elapsed: 1.802 sec <<< ERROR! java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568) at com.yourmediashelf.fedora.client.request.AddDatastream.execute(AddDatastream.java:232) at....addLargeStream(FedoraRepositoryIT.java:115) I think, this problem is related to http://stackoverflow.com/questions/11176824/preventing-the-jersey-client-from-causing-an-outofmemory-error-when-posting-larg And work around would be use ApacheHttpClient instead of HttpURLConection in com.yourmediashelf.fedora.client.FedoraClent constructor. Something like: /** * Constructor for FedoraClient. * * @param fc credentials for a Fedora repository */ public FedoraClient(FedoraCredentials fc) { this.fc = fc; // TODO validate fc // null check for username & password // null check for baseUrl ClientConfig config = new DefaultClientConfig(); //added config.getProperties().put(DefaultApacheHttpClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE, 0); //added // FIXME this isn't very security-minded if (fc.getBaseUrl().toString().startsWith("https")) { SSLContext ctx = null; try { ctx = SSLContext.getInstance("SSL"); ctx.init(null, null, null); } catch (NoSuchAlgorithmException e) { logger.error(e.getMessage(), e); } catch (KeyManagementException e) { logger.error(e.getMessage(), e); } // FIXME Consider using not-yet-commons-ssl hostnameverifier // config by property: strict, none, etc. config.getProperties().put( HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null, ctx)); client = ApacheHttpClient.create(config); } else { client = ApacheHttpClient.create(config); //changed } client.setFollowRedirects(true); client.addFilter(new HTTPBasicAuthFilter(fc.getUsername(), fc .getPassword())); }
    via by Pavel,
  • Where are problems uploading big files to fedora using fedora-client v0.7 Test to reproduce bug: @Test public void addLargeStreamToFedora() throws IOException, FedoraClientException { FedoraCredentials fedoraCredentials = new FedoraCredentials("http://localhost:8085/fedora", "fedoraAdmin", "<password>"); FedoraClient fedoraClient = new FedoraClient(fedoraCredentials); AddDatastream addStream = new AddDatastream("test:atest1", "MAIN"); addStream.mimeType("application/pdf"); addStream.controlGroup("M"); addStream.dsLabel("ds_label_1"); Path filePath = Paths.get("<path to large file>"); InputStream is = Files.newInputStream(filePath); addStream.content(is); new Ingest("test:atest1").ownerId("test").execute(fedoraClient); addStream.execute(fedoraClient); //java.lang.OutOfMemoryError: Java heap space } stack trace: addLargeStream(...FedoraRepositoryIT) Time elapsed: 1.802 sec <<< ERROR! java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568) at com.yourmediashelf.fedora.client.request.AddDatastream.execute(AddDatastream.java:232) at....addLargeStream(FedoraRepositoryIT.java:115) I think, this problem is related to http://stackoverflow.com/questions/11176824/preventing-the-jersey-client-from-causing-an-outofmemory-error-when-posting-larg And work around would be use ApacheHttpClient instead of HttpURLConection in com.yourmediashelf.fedora.client.FedoraClent constructor. Something like: /** * Constructor for FedoraClient. * * @param fc credentials for a Fedora repository */ public FedoraClient(FedoraCredentials fc) { this.fc = fc; // TODO validate fc // null check for username & password // null check for baseUrl ClientConfig config = new DefaultClientConfig(); //added config.getProperties().put(DefaultApacheHttpClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE, 0); //added // FIXME this isn't very security-minded if (fc.getBaseUrl().toString().startsWith("https")) { SSLContext ctx = null; try { ctx = SSLContext.getInstance("SSL"); ctx.init(null, null, null); } catch (NoSuchAlgorithmException e) { logger.error(e.getMessage(), e); } catch (KeyManagementException e) { logger.error(e.getMessage(), e); } // FIXME Consider using not-yet-commons-ssl hostnameverifier // config by property: strict, none, etc. config.getProperties().put( HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null, ctx)); client = ApacheHttpClient.create(config); } else { client = ApacheHttpClient.create(config); //changed } client.setFollowRedirects(true); client.addFilter(new HTTPBasicAuthFilter(fc.getUsername(), fc .getPassword())); }
    via by Pavel,
  • Azure SDK OutofMemoryError
    via Stack Overflow by Klaus
    ,
  • Running import-export.sh I was getting out of memory exceptions. I had to edit the script to pass in parameters to increase memory: "$_PENTAHO_JAVA" -Xmx2048m -Xms1024m -XX:MaxPermSize=320m -XX:PermSize=320m -classpath "$DIR/tomcat/webapps/pentaho/WEB-INF/lib/*" org.pentaho.platform.plugin.services.importexport.CommandLineProcessor $@ ./import-export.sh --import --url=http://localhost:8080/pentaho --username=admin --password=password --source=file-system --type=files --charset=UTF-8 --path=/public --file-path=/Users/skarmali/pentaho/biserver-ee-builds/biserver-ee/pentaho-solutions.zip --overwrite=true --retainOwnership=true --permission=true --logfile=./import.log /Users/skarmali/pentaho/biserver-ee-builds/biserver-ee /Users/skarmali/pentaho/biserver-ee-builds/biserver-ee WARNING: Using java from path DEBUG: _PENTAHO_JAVA_HOME= DEBUG: _PENTAHO_JAVA=java DEBUG: PENTAHO_INSTALLED_LICENSE_PATH= Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59) at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:218) at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:71) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.performImportREST(CommandLineProcessor.java:719) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.performImport(CommandLineProcessor.java:439) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.main(CommandLineProcessor.java:290)
    via by Sulaiman Karmali,
  • Running import-export.sh I was getting out of memory exceptions. I had to edit the script to pass in parameters to increase memory: "$_PENTAHO_JAVA" -Xmx2048m -Xms1024m -XX:MaxPermSize=320m -XX:PermSize=320m -classpath "$DIR/tomcat/webapps/pentaho/WEB-INF/lib/*" org.pentaho.platform.plugin.services.importexport.CommandLineProcessor $@ ./import-export.sh --import --url=http://localhost:8080/pentaho --username=admin --password=password --source=file-system --type=files --charset=UTF-8 --path=/public --file-path=/Users/skarmali/pentaho/biserver-ee-builds/biserver-ee/pentaho-solutions.zip --overwrite=true --retainOwnership=true --permission=true --logfile=./import.log /Users/skarmali/pentaho/biserver-ee-builds/biserver-ee /Users/skarmali/pentaho/biserver-ee-builds/biserver-ee WARNING: Using java from path DEBUG: _PENTAHO_JAVA_HOME= DEBUG: _PENTAHO_JAVA=java DEBUG: PENTAHO_INSTALLED_LICENSE_PATH= Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59) at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:218) at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:71) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.performImportREST(CommandLineProcessor.java:719) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.performImport(CommandLineProcessor.java:439) at org.pentaho.platform.plugin.services.importexport.CommandLineProcessor.main(CommandLineProcessor.java:290)
    via by Sulaiman Karmali,
  • which one to go to fix this? 1. <env key="MAVEN_OPTS" value="-Xmx1024m"/> 2. <jvmarg value="-Xmx1024m"/> deploy: [artifact:mvn] [INFO] Scanning for projects... [artifact:mvn] [INFO] ------------------------------------------------------------------------ [artifact:mvn] [INFO] Building Maven Default Project [artifact:mvn] [INFO] task-segment: [org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file] (aggregator-style) [artifact:mvn] [INFO] ------------------------------------------------------------------------ [artifact:mvn] [INFO] [deploy:deploy-file] [artifact:mvn] Uploading: http://dev.abc.com:8081/nexus/content/repositories/releases/com/abc/dev/lib-initial-state/0.1.87/lib-initial-state-0.1.87.zip [artifact:mvn] [INFO] ------------------------------------------------------------------------ [artifact:mvn] [ERROR] FATAL ERROR [artifact:mvn] [INFO] ------------------------------------------------------------------------ [artifact:mvn] [INFO] Java heap space [artifact:mvn] [INFO] ------------------------------------------------------------------------ [artifact:mvn] [INFO] Trace [artifact:mvn] java.lang.OutOfMemoryError: Java heap space [artifact:mvn] at java.util.Arrays.copyOf(Arrays.java:2271) [artifact:mvn] at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) [artifact:mvn] at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) [artifact:mvn] at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) [artifact:mvn] at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) [artifact:mvn] at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:338) [artifact:mvn] at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:305) [artifact:mvn] at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java
    via by babu ravi teja nallamothu,
  • Hessian with large binary file
    via Stack Overflow by dimitri
    ,
    • java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78) at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90) at com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115) at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98) at com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59) at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213) at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104) at com.sun.jersey.api.client.Client.handle(Client.java:648) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568) at com.yourmediashelf.fedora.client.request.AddDatastream.execute(AddDatastream.java:232)

    Users with the same issue

    Unknown visitor1 times, last one,
    David
    David1 times, last one,
    Handemelindo
    Handemelindo1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    49 more bugmates