title: How to increase jvm heap size pro-grammatically while project is on aws-lambda
body: <p>I have developed aws-lambda function, that collects pptx file sources from s3 bucket and builds a new presentation from given sources. 
  But if the size of the sourec files is large, then I'm getting ERROR:  </p>
  
  <pre><code>{
    "errorMessage": "Java heap space",
    "errorType": "java.lang.OutOfMemoryError",
    "stackTrace": [
      "com.aspose.slides.internal.e5.void.setCapacity(Unknown Source)",
      "com.aspose.slides.internal.e5.void.b(Unknown Source)",
      "com.aspose.slides.internal.e5.void.write(Unknown Source)",
      "com.aspose.slides.internal.eu.case.write(Unknown Source)",
      "com.aspose.slides.internal.eu.case.write(Unknown Source)",
      "com.aspose.slides.internal.eu.boolean.write(Unknown Source)",
      "com.aspose.slides.internal.eu.goto.write(Unknown Source)",
      "com.aspose.slides.internal.eu.public.byte(Unknown Source)",
      "com.aspose.slides.internal.eu.public.case(Unknown Source)",
      "com.aspose.slides.internal.eu.public.int(Unknown Source)",
      "com.aspose.slides.internal.eu.switch.public(Unknown Source)",
      "com.aspose.slides.internal.eu.switch.if(Unknown Source)",
      "com.aspose.slides.acy.do(Unknown Source)",
      "com.aspose.slides.Presentation.do(Unknown Source)",
      "com.aspose.slides.Presentation.do(Unknown Source)",
      "com.aspose.slides.Presentation.do(Unknown Source)",
      "com.aspose.slides.Presentation.save(Unknown Source)",
      "com.prdxn.testing.demo.LambdaFunctionHandler.handleRequest(LambdaFunctionHandler.java:60)",
      "com.prdxn.testing.demo.LambdaFunctionHandler.handleRequest(LambdaFunctionHandler.java:1)"
    ]
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class LambdaFunctionHandler implements RequestHandler&lt;Map&lt;String, String[]&gt;, String&gt; {
      @Override
      public String handleRequest(Map&lt;String, String[]&gt; input, Context context) {
          // AWS S3 bucket configuration..
          String AccessKeyID = "xxx";
          String SecretAccessKey = "xxx";
          String clientRegion = "xxx";
          String bucket_name = "xxx";
          BasicAWSCredentials creds = new BasicAWSCredentials(AccessKeyID, SecretAccessKey);
          AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withRegion(clientRegion)
                  .withCredentials(new AWSStaticCredentialsProvider(creds)).build();
          // Closing AWS S3 bucket configuration..
  
          Presentation finalPresentation = new Presentation();
          ISlideCollection finalPresentationSlides = finalPresentation.getSlides();
  
          String dest = "result.pptx";
          String[] keys = input.get("keys"); // get pptx file name from s3 bucket
          for (int i = 0; i &lt; keys.length; i++) {
              String key_name = keys[i];
              Presentation sourcePresentation = new Presentation(
                      s3Client.getObject(bucket_name, key_name).getObjectContent());
              try {
  
                  finalPresentationSlides.addClone(sourcePresentation.getSlides().get_Item(0));
  
              } catch (Exception e) {
                  e.printStackTrace();
              } finally {
                  sourcePresentation.dispose();
              }
          }
  
          final StreamTransferManager manager = new StreamTransferManager(bucket_name, dest, s3Client);
          MultiPartOutputStream os = null;
  
          try {
              os = manager.getMultiPartOutputStreams().get(0);
              finalPresentation.save(os, SaveFormat.Pptx);
  
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              os.close();
          }
          manager.complete();
          // Finishing of
          return "success";
      }
  }
  </code></pre>