# Limiting Discourse memory usage on a dedicaded box

**URL:** https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378
**Category:** Self-hosting
**Tags:** hosting
**Created:** [8월 28, 2014, 8:20오전 UTC](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378 "2014-08-28T08:20:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rjd22](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rjd22/32/114685_2.png) [@rjd22](https://meta.discourse.org/u/rjd22)
#### Post date: [8월 28, 2014, 8:20오전 UTC](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378/1 "2014-08-28T08:20:33Z")

</div>

I’m hosting a discourse forum on one of my dedicaded server. The problem is that as it is now to can use the full 32GB memory that is on the dedicaded box (this already happened once).

What is the best way to edit the launcher or config file to limit how memory much the docker instance will use?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [8월 28, 2014, 8:59오전 UTC](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378/2 "2014-08-28T08:59:46Z")

</div>

Docker [allows limiting the memory](http://docs.docker.com/reference/run/#runtime-constraints-on-cpu-and-memory) with the `-m` option.  
However, I don’t think that the launcher can do this out of the box at the moment. You’ll probably need to change it within the `launcher` script.

---

<div class="post-metadata">

### Author: ![rjd22](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rjd22/32/114685_2.png) [@rjd22](https://meta.discourse.org/u/rjd22)
#### Post date: [8월 28, 2014, 6:30오후 UTC](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378/3 "2014-08-28T18:30:51Z")

</div>

What would be the best way to edit the launcher script. Are there any recommendations on what to change?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [8월 28, 2014, 6:58오후 UTC](https://meta.discourse.org/t/limiting-discourse-memory-usage-on-a-dedicaded-box/19378/4 "2014-08-28T18:58:39Z")

</div>

I haven’t tested this yet, but changing [line 289 in the current launcher](https://github.com/discourse/discourse_docker/blob/5701c085f4773dce8943ec145a0f808ac5fbef3a/launcher#L289) script to the following should work.

```
$docker_path run $restart_policy "${env[@]}" -h "`hostname`-$config" -m="4g" -e DOCKER_HOST_IP=$docker_ip --name $config -t --cidfile $cidfile $ports \

```

I’ve added `-m="4g"` in order to limit the container to 4GB of memory.

> [@Docker Documentation](#):
>
> -m=“”: Memory limit (format: , where unit = b, k, m or g)
