java.lang.OutOfMemoryError: Java heap space

Sakai JIRA | Pavel | 3 years ago
  1. 0

    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())); }

    Sakai JIRA | 3 years ago | Pavel
    java.lang.OutOfMemoryError: Java heap space
  2. 0

    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())); }

    Sakai JIRA | 3 years ago | Pavel
    java.lang.OutOfMemoryError: Java heap space
  3. 0

    Azure SDK OutofMemoryError

    Stack Overflow | 3 years ago | Klaus
    java.lang.OutOfMemoryError: Java heap space
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    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)

    Pentaho BI Platform Tracking | 3 years ago | Sulaiman Karmali
    java.lang.OutOfMemoryError: Java heap space
  6. 0

    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)

    Pentaho BI Platform Tracking | 3 years ago | Sulaiman Karmali
    java.lang.OutOfMemoryError: Java heap space

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.OutOfMemoryError

      Java heap space

      at java.util.Arrays.copyOf()
    2. Java RT
      PosterOutputStream.write
      1. java.util.Arrays.copyOf(Arrays.java:2271)
      2. java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
      3. java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
      4. java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
      5. sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:78)
      5 frames
    3. jersey-client
      CommittingOutputStream.write
      1. com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:90)
      1 frame
    4. jersey-core
      InputStreamProvider.writeTo
      1. com.sun.jersey.core.util.ReaderWriter.writeTo(ReaderWriter.java:115)
      2. com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeTo(AbstractMessageReaderWriterProvider.java:76)
      3. com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:98)
      4. com.sun.jersey.core.impl.provider.entity.InputStreamProvider.writeTo(InputStreamProvider.java:59)
      4 frames
    5. jersey-client
      WebResource$Builder.post
      1. com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:300)
      2. com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:213)
      3. com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149)
      4. com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:104)
      5. com.sun.jersey.api.client.Client.handle(Client.java:648)
      6. com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
      7. com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
      8. com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
      8 frames
    6. com.yourmediashelf.fedora
      AddDatastream.execute
      1. com.yourmediashelf.fedora.client.request.AddDatastream.execute(AddDatastream.java:232)
      1 frame