anchor.diff:      - name: YOUR-APP
         memory: 1G
         env:
  -        JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {memory_sizes: {native: 150m}}]'
  +        JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {headroom: 10}}]'
       ```
       Where `YOUR-APP` is the name of your app.
   
  -    This example shows that `150m` of the overall available `1G` is reserved for anything that is not `heap`, `metaspace`, or `permgen`. In less common cases, this may come from companion processes started by the JVM, such as the Process API.
  -
  -    For more information about measuring how much `native` memory a Java app needs, see [Native Memory Tracking](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html) in the Java documentation. For more information about configuring the Java buildpack using the `native` setting, see [OpenJDK JRE](https://github.com/cloudfoundry/java-buildpack/blob/main/docs/jre-open_jdk_jre.md#memory-sizes) in the Cloud Foundry Java Buildpack on GitHub. For more information about the Process API, see [Class Process](https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html) in the Java documentation.
  -
  -* **Cause 2 - High thread count**: Java threads in the JVM can cause memory errors at the Garden level. When an app is under heavy load, it uses a high number of threads and consumes a significant amount of memory.
  +    This example shows that `10%` of the overall available `1G` is reserved for anything that is not `heap`, `metaspace`, `direct`, `code cache` or `threads`. In less common cases, this may come from companion processes started by the JVM, such as the Process API.
  +
  +    For more information about measuring how much `native` memory a Java app needs, see [Native Memory Tracking](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr007.html) in the Java documentation. For more information about configuring the Java buildpack using the `native` setting, see [OpenJDK JRE](https://github.com/cloudfoundry/java-buildpack/blob/main/docs/jre-open_jdk_jre.md#memory) in the Cloud Foundry Java Buildpack on GitHub. For more information about the Process API, see [Class Process](https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html) in the Java documentation.
  +
  +* **Cause 2 - High thread count**: Java threads in the JVM can cause memory errors at the Garden level. When an app is under heavy load, it uses a high number of threads. Each thread consume some memory and if there are enough threads they will consume a significant amount of memory.
   
   * **Solution 2**: Set the reserved memory for stack traces to the correct value for your app.
   <br>
  -<br>You can use the `stack` setting of the memory calculator to configure the amount of space the JVM reserves for each Java thread. You must multiply this value by the number of threads your app requires. Specify the number of threads in the `stack_threads` setting of the memory calculator. For example, if you estimate the max thread count for an app at `800` and the amount of memory needed to represent the deepest stacktrace of a Java thread is `512KB`, configure the memory calculator as follows:
  +<br>You can use the `-Xss` setting of the JVM to configure the amount of space the JVM reserves for each Java thread. You must multiply this value by the number of threads your app requires. Specify the number of threads in the `stack_threads` setting of the memory calculator. For example, if you estimate the max thread count for an app at `800` and the amount of memory needed to represent the deepest stacktrace of a Java thread is `512KB`, configure the memory calculator as follows:
   
       ```
       ---
  
positive.code: As an example, pushing a WAR file that is bound to a PostgreSQL database and New Relic for performance monitoring results in the following:
  
  <pre class="terminal">
  Initialized empty Git repository in /tmp/buildpacks/java-buildpack/.git/
  --> Java Buildpack source: https://github.com/cloudfoundry/java-buildpack#0928916a2dd78e9faf9469c558046eef09f60e5d
  --> Downloading Open Jdk JRE 1.7.0_51 from
        http://.../openjdk/lucid/x86_64/openjdk-1.7.0_51.tar.gz (0.0s)
          Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.9s)
  --> Downloading New Relic Agent 3.4.1 from
        http://.../new-relic/new-relic-3.4.1.jar (0.4s)
  --> Downloading Postgresql JDBC 9.3.1100 from
        http://.../postgresql-jdbc/postgresql-jdbc-9.3.1100.jar (0.0s)
  --> Downloading Spring Auto Reconfiguration 0.8.7 from
        http://.../auto-reconfiguration/auto-reconfiguration-0.8.7.jar (0.0s)
          Modifying /WEB-INF/web.xml for Auto Reconfiguration
  --> Downloading Tomcat 7.0.50 from
        http://.../tomcat/tomcat-7.0.50.tar.gz (0.0s)
          Expanding Tomcat to .java-buildpack/tomcat (0.1s)
  --> Downloading Buildpack Tomcat Support 1.1.1 from
        http://.../tomcat-buildpack-support/tomcat-buildpack-support-1.1.1.jar (0.1s)
  --> Uploading droplet (57M)
  </pre>
  
  
  ## <a id='configuration'></a> Configuration
  
  In most cases, the buildpack should work without any configuration. If you are new to <%= vars.app_runtime_abbr %>, <%= vars.recommended_by %> recommends that you make your first attempts without modifying the buildpack configuration. If the buildpack requires some configuration, use a fork of the buildpack. For more information, see [Configuration and Extension](https://github.com/cloudfoundry/java-buildpack#configuration-and-extension) in the Cloud Foundry Java Buildpack repository on GitHub.
  
  
  ## <a id='java-client-library'></a> Java Client Library
  
  The Cloud Foundry Client Library provides a Java API for interacting with a <%= vars.app_runtime_abbr %> instance. This library, `cloudfoundry-client-lib`, is used by the Cloud Foundry Maven plugin, the Cloud Foundry Gradle plugin, and other Java-based tools.
  
  For information about using this library, see [Java Cloud Foundry Library](./java-client.html).
  
  
negative.code: 
      This error appears when the JVM allocates more OS-level memory than the quota requested by the app, such as through the manifest.
  
  * **Cause 1 - Insufficient native memory**: This error commonly means that the JVM requires more `native` memory. In the scope of the Java buildpack and the memory calculator, the term `native` means the memory required for the JVM to work, along with forms of memory not covered in the other classifications of the memory calculator. This includes the memory footprint of OS-level threads, program counters, if an app forks and runs subprocesses, or if an app uses JNI to allocate memory.
  
  * **Solution 1**: Determine how much `native` memory a Java app needs by measuring it with realistic workloads and fine-tuning it accordingly. You can then configure the Java buildpack using the `native` setting of the memory calculator, as in the example below:
  
  