Skip to content

Commit

Permalink
Merge pull request #567 from geoffreymersch/CLDOPS-12730_add_max_meta…
Browse files Browse the repository at this point in the history
…space_size_env_variable

configure max_metaspace_size as env variable
  • Loading branch information
svanderburg authored Aug 17, 2022
2 parents 89bd92e + a69a5cb commit 2455d54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Release notes are available for the [buildpack](https://github.com/mendix/cf-men
- [Java Configuration](#java-configuration)
- [Java Version](#java-version)
- [Java Heap Size](#java-heap-size)
- [Java Max Metaspace Size](#java-max-metaspace-size)
- [Java Virtual Machine (JVM) Settings](#java-virtual-machine-jvm-settings)
- [Certificate Authorities](#certificate-authorities)
- [Built-In Proxy Configuration](#built-in-proxy-configuration)
Expand Down Expand Up @@ -435,6 +436,14 @@ The Java heap size is configured automatically based on best practices. You can
```shell
cf set-env <YOUR_APP> HEAP_SIZE 512M
```
### Java Max Metaspace Size

The Java Max Metaspace Size is configured automatically based on best practices. You can tweak this to your needs by using another environment variable, in which case it is used directly.

```shell
cf set-env <YOUR_APP> MAX_METASPACE_SIZE 512M
```


### Java Virtual Machine (JVM) Settings

Expand Down
6 changes: 4 additions & 2 deletions buildpack/core/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ def _set_jvm_memory(m2ee, vcap):
heap_size = str(heap_size) + "M"

env_heap_size = os.environ.get("HEAP_SIZE")
max_metaspace_size = os.getenv("MAX_METASPACE_SIZE", "256M")

util.upsert_javaopts(m2ee, "-XX:MaxMetaspaceSize=%s" % max_metaspace_size)

if env_heap_size:
if int(env_heap_size[:-1]) < limit:
heap_size = env_heap_size
Expand All @@ -319,8 +323,6 @@ def _set_jvm_memory(m2ee, vcap):
util.upsert_javaopts(m2ee, "-Xmx%s" % heap_size)
util.upsert_javaopts(m2ee, "-Xms%s" % heap_size)

util.upsert_javaopts(m2ee, "-XX:MaxMetaspaceSize=256M")

logging.debug("Java heap size set to %s", heap_size)

if os.getenv("MALLOC_ARENA_MAX"):
Expand Down

0 comments on commit 2455d54

Please sign in to comment.