# Windows Docker - Keycloak memory limits

**URL:** <https://forum.keycloak.org/t/windows-docker-keycloak-memory-limits/8416>\
**Category:** Configuring the server\
**Created:** [April 9, 2021, 2:13pm UTC](https://forum.keycloak.org/t/windows-docker-keycloak-memory-limits/8416 "2021-04-09T14:13:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcuser](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@kcuser](https://forum.keycloak.org/u/kcuser)\
**Post date:** [April 9, 2021, 2:13pm UTC](https://forum.keycloak.org/t/windows-docker-keycloak-memory-limits/8416/1 "2021-04-09T14:13:20Z")

</div>

Hello,

I was checking the Server Info on my current dev Windows docker instance of Keycloak and I was wondering about the stated memory limits, currently it tells me I have a Total Memory of ‘512 MB’ but for the docker container on creation I set it up with 2GB:

![kc-mem](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/7/7befc48b086d9ed57dfe521f43a2d042f823a9d7.png)

If I check the docker container via PowerShell I can see it has a 2GB limit and 537.8MB in use:

 ![mem-usage](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/0/070aecd61832d36d14f7a3f65331acdb0c63793d.png)

How can I increase the Total memory for my Keycloak instance? The container itself will only run Keycloak and nothing else so makes sense for the limit to be increased.

Thanks for any help!

Steve

---

<div class="post-metadata">

**Author:** ![kcuser](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@kcuser](https://forum.keycloak.org/u/kcuser)\
**Post date:** [April 10, 2021, 11:44am UTC](https://forum.keycloak.org/t/windows-docker-keycloak-memory-limits/8416/2 "2021-04-10T11:44:17Z")

</div>

This one seems to be related to the JVM inside the container being set to take a maximum of 25% RAM (_I think_):

 ![jvm-mem](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/6/6119aff1cc105681551997cd1cf46b7e2b957e3f.png)

I’ve increased that via calls on a running container using `-XX:MaxRAM` and `-XX:MaxRAMPercentage` but it hasn’t changed the Total Memory output on Keycloak’s ‘Server Info’ page (I’m assuming the JVM needs to start afresh), I’m trying different ways to see if I can increase the RAM usage with those commands on the initial Docker run call but no joy so far.

---

<div class="post-metadata">

**Author:** ![kcuser](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@kcuser](https://forum.keycloak.org/u/kcuser)\
**Post date:** [April 10, 2021, 12:19pm UTC](https://forum.keycloak.org/t/windows-docker-keycloak-memory-limits/8416/3 "2021-04-10T12:19:55Z")

</div>

Ok I’ve potentially had some success using the following as a test:

`docker run --name keycloak --memory 3072m ... ...... -e JAVA_OPTS_APPEND="-server -Xms1024m -Xmx2048m"`

Which sets an initial heap size (Xms) of 1gb and then a max heap size (Xmx) of 2gb on a container with 3gb and is also indicated on the ‘Server Info’ page:

![kc-mem](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/9/95e6062297cfdddcdb6b7b3ee8252e2ec6d7e807.png)

The container is currently using 1gb according to the stats (shown below) and I’m assuming that will increase to 2gb if Keycloak needs it:

 ![container](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/5/5b6bcd7a9aa13a116adbfc29c7a03c07378b366f.png)

I don’t know the full implications of this yet because I haven’t tested load in a live environment but it’s encouraging at least. It would be good to have more info on ths type of thing on the Keycloak docker readme ([https://github.com/keycloak/keycloak-containers/blob/12.0.4/server/README.md](https://github.com/keycloak/keycloak-containers/blob/12.0.4/server/README.md)) but maybe it’s out of scope / risky to play around with? I tried to find info about whether it’s automcatically setup with UseContainerSupport and automatically expanding RAM but couldn’t find the details about this.
