# Si verifica un crash con errore out of memory all'apertura di un argomento

**URL:** https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983
**Category:** Support
**Tags:** server-resources
**Created:** [19 Gennaio 2019, 6:26pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983 "2019-01-19T18:26:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![BDub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bdub/32/108566_2.png) [@BDub](https://meta.discourse.org/u/BDub)
#### Post date: [19 Gennaio 2019, 6:26pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/1 "2019-01-19T18:26:53Z")

</div>

I have the latest version of discourse running on a 2GB / 1CPU / 40GB SSD Ubuntu 14.04.5 DigitalOcean droplet. It has been fine for the longest time, and I recently resized the old plan that was the same specs from $20/mo. to this one that is $10/mo. After resizing everything it was running and very snappy (better than before I’d say), but now it will load the main site but if I click on any topics it won’t load and ends up crashing the instance.

Any advice on where to go digging for the right logs?

---

<div class="post-metadata">

### Author: ![BDub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bdub/32/108566_2.png) [@BDub](https://meta.discourse.org/u/BDub)
#### Post date: [19 Gennaio 2019, 6:42pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/2 "2019-01-19T18:42:11Z")

</div>

I can get to the error logs from the admin panel if that’s helpful:

 ![50%20AM](https://global.discourse-cdn.com/meta/original/3X/0/9/0982647900cf07f41a3ca971667d2067b07ae02b.png)

Here’s the details of the `deadlock; recursive locking` error

> <https://pastebin.com/aL3iZkZM>

---

<div class="post-metadata">

### Author: ![ssvenn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ssvenn/32/86740_2.png) [@ssvenn](https://meta.discourse.org/u/ssvenn)
#### Post date: [19 Gennaio 2019, 7:12pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/3 "2019-01-19T19:12:04Z")

</div>

“failed to allocate memory” sounds like maybe the database is tuned to use too much ram from the previous plan, my empty test instance uses about 1gb on a 4gb centos vm

```
[root@discocent discourse]# free
              total used free shared buff/cache available
Mem: 3881412 912764 413192 33168 2555456 2401820
Swap: 2097148 1544 2095604

```

Does the droplet have any swap configured? Have you tried rebuilding the app container?  
Check for out-of-memory errors in dmesg or /var/log/syslog too

Try to tail -f /var/discourse/shared/standalone/log/rails/production.log when opening a topic and look for error messages there maybe, that log is pretty verbose.

---

<div class="post-metadata">

### Author: ![BDub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bdub/32/108566_2.png) [@BDub](https://meta.discourse.org/u/BDub)
#### Post date: [19 Gennaio 2019, 7:34pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/4 "2019-01-19T19:34:39Z")

</div>

Yes I tried rebuilding which finishes fine and loads the site.

Memory available should be the same as before, 2GB.

It does appear something is consuming up all of the memory… and there are lots of threads on here that say discourse can run on the smallest droplet. My site is basically a ghost town as well.. so nothing should be consuming so much RAM.

Oh here we go…

### this is just after rebooting the disc, running `free -m` every second.

```plaintext
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 756 1245 22 77 271
-/+ buffers/cache: 407 1594
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 878 1123 28 92 289
-/+ buffers/cache: 497 1504
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 961 1040 28 99 330
-/+ buffers/cache: 532 1469
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 1022 978 28 99 389
-/+ buffers/cache: 534 1467
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 1328 673 28 99 456
-/+ buffers/cache: 772 1229
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 1744 257 32 99 467
-/+ buffers/cache: 1177 824
Swap: 0 0 0
root@test:~# free -m
             total used free shared buffers cached
Mem: 2001 1938 62 35 77 448
-/+ buffers/cache: 1413 588
Swap: 0 0 0

```

I’ll try digging into the various logs, thanks!

---

<div class="post-metadata">

### Author: ![ssvenn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ssvenn/32/86740_2.png) [@ssvenn](https://meta.discourse.org/u/ssvenn)
#### Post date: [19 Gennaio 2019, 7:44pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/5 "2019-01-19T19:44:19Z")

</div>

Check out [High-CPU / High memory on fresh discourse install](https://meta.discourse.org/t/high-cpu-high-memory-on-fresh-discourse-install/99699) and [Discourse 2.2.0.beta8 Release Notes](https://meta.discourse.org/t/discourse-2-2-0-beta8-release-notes/105915)

> **Important Note:** Expect high CPU usage for a few hours after this upgrade due to image re-optimization. Sites with large numbers of images may see high CPU usage for a longer period of time.

It could be that you need to tune the number of unicorn workers and reduce the cache size for the database for that initial optimization to work.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [19 Gennaio 2019, 7:52pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/6 "2019-01-19T19:52:06Z")

</div>

You need to configure swap.

Try running this to configure swap:

> <https://github.com/discourse/discourse_docker/blob/master/discourse-setup#L141-L147>

---

<div class="post-metadata">

### Author: ![BDub](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bdub/32/108566_2.png) [@BDub](https://meta.discourse.org/u/BDub)
#### Post date: [19 Gennaio 2019, 8:10pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/7 "2019-01-19T20:10:03Z")

</div>

Thanks @Falco that did the trick! It appears to be stable now 😄

```plaintext
# free -m
             total used free shared buffers cached
Mem: 2001 1922 79 28 49 306
-/+ buffers/cache: 1566 435
Swap: 2047 0 2047

```

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [23 Gennaio 2019, 3:14pm UTC](https://meta.discourse.org/t/crashing-with-out-of-memory-error-when-opening-a-topic/106983/8 "2019-01-23T15:14:24Z")

</div>


