# NC Box memory exhausted

**URL:** <https://help.nextcloud.com/t/nc-box-memory-exhausted/4183>\
**Category:** ℹ️ Support\
**Created:** [October 14, 2016, 9:01pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183 "2016-10-14T21:01:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [October 14, 2016, 9:01pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/1 "2016-10-14T21:01:10Z")

</div>

I appreciate with the severely limited amount of memory available on the Pi this is somewhat unavoidable and the NC crew may have already optimised the snap as best as possible, but… any suggestions?

```
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:47:35+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:47:34+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:47:34+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:47:00+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:46:57+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:46:55+00:00	jason
Error	PHP	Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) at /snap/nextcloud/99/htdocs/lib/private/image.php#427	2016-10-09T12:46:29+00:00	jason
```

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [October 15, 2016, 9:51am UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/2 "2016-10-15T09:51:54Z")

</div>

Looks like your php memory limit is 128MB. The RPi2/3 has 1GB of RAM, so you probably can increase that value a bit (256 MB should be no problem).

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [October 15, 2016, 10:58am UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/3 "2016-10-15T10:58:48Z")

</div>

And that’s all it is? Well I feel silly…

But then this could have been pre-set within the snap so perhaps I should raise an issue.

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_22734026db12803ebb3e059622ac3534.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [October 15, 2016, 12:30pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/4 "2016-10-15T12:30:30Z")

</div>

Yes, check it out if it works for you and how you balance the memory best between php, webserver, and database. Not sure if they have optimized it yet since it is the default setting.

---

<div class="post-metadata">

**Author:** ![Pivo64](https://help.nextcloud.com/letter_avatar/pivo64/32/6_22734026db12803ebb3e059622ac3534.png) [@Pivo64](https://help.nextcloud.com/u/Pivo64)\
**Post date:** [October 21, 2016, 1:48pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/5 "2016-10-21T13:48:00Z")

</div>

Hello, I have the same issue but I have no idea how to increase the memory limit, since this is a snap version and the ‘php.ini’ is not editable for me. any ideas?

---

<div class="post-metadata">

**Author:** ![Guillaume](https://help.nextcloud.com/letter_avatar/guillaume/32/6_22734026db12803ebb3e059622ac3534.png) [@Guillaume](https://help.nextcloud.com/u/Guillaume)\
**Post date:** [November 16, 2016, 6:05pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/6 "2016-11-16T18:05:44Z")

</div>

same memory problem. I think that the solution is in file /snap/nextcloud/current/config/php/php.ini  
the following lines :  
; Maximum amount of memory a script may consume (128MB)  
; [http://php.net/memory-limit](http://php.net/memory-limit)  
memory\_limit = 128M

but it is not possible to edit this file, even with sudo …

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [November 17, 2016, 8:56am UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/7 "2016-11-17T08:56:05Z")

</div>

There’s not enough control over the variables in the snap. They’ve properly locked it down to accomodate the most tech-averse users ☹

---

<div class="post-metadata">

**Author:** ![Raudn](https://help.nextcloud.com/letter_avatar/raudn/32/6_22734026db12803ebb3e059622ac3534.png) [@Raudn](https://help.nextcloud.com/u/Raudn)\
**Post date:** [December 7, 2016, 6:06pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/8 "2016-12-07T18:06:39Z")

</div>

same problem here. Memory gets exhausted and the gallery can’t create the thumbnails. In the past I managed to change php.ini but now the value is somehow back to 128M and can’t be edited, even with SUDO. Trying to change ownerwship of the php.ini file results in "chown: changing ownership of ‘php.ini’: Read-only file system"  
Anybody solved this issue?

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [December 7, 2016, 6:21pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/9 "2016-12-07T18:21:56Z")

</div>

No - limitations of the snap I guess. @oparoz

---

<div class="post-metadata">

**Author:** ![Raudn](https://help.nextcloud.com/letter_avatar/raudn/32/6_22734026db12803ebb3e059622ac3534.png) [@Raudn](https://help.nextcloud.com/u/Raudn)\
**Post date:** [December 7, 2016, 6:32pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/10 "2016-12-07T18:32:41Z")

</div>

strange thing is that I remember changing the value and it worked for a while. Now that the limit is back to 128M I don’t trust my memory anymore. Could I have set it somewhere else?

---

<div class="post-metadata">

**Author:** ![oparoz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oparoz/32/135_2.png) [@oparoz](https://help.nextcloud.com/u/oparoz)\
**Post date:** [December 9, 2016, 11:36am UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/11 "2016-12-09T11:36:44Z")

</div>

So, yes, unfortunately, you can’t change PHP settings in this snap. The only solution is to fork the project for advanced users or wait until snapweb and the Nextcloud snap support config changes.

But I wouldn’t recommend raising the limit on a Pi, it would be asking for trouble 😉

---

<div class="post-metadata">

**Author:** ![Raudn](https://help.nextcloud.com/letter_avatar/raudn/32/6_22734026db12803ebb3e059622ac3534.png) [@Raudn](https://help.nextcloud.com/u/Raudn)\
**Post date:** [December 9, 2016, 2:08pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/12 "2016-12-09T14:08:51Z")

</div>

I just observed that it actually doesn’t seem to be depending on the size or dimension of the file (my photos all have the same dimension 5472x3648 but the size varies from 4-9 MB) - Currently it gets stuck on a 4 MB file while the thumbnail of the 9 MB file was created just fine.

Can I provide any other data (e.g. logs) that will help you to analyze the issue?

Or are are saying is that the gallery on my Nextcloud box will not work and I will not be able to make it work. Well, this would be a huge drawback for me and I guess for anyone using a similar or better camera.

This wouldn’t make me happy.

---

<div class="post-metadata">

**Author:** ![oparoz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oparoz/32/135_2.png) [@oparoz](https://help.nextcloud.com/u/oparoz)\
**Post date:** [December 9, 2016, 2:36pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/13 "2016-12-09T14:36:34Z")

</div>

It’s not related to the weight, but to the dimensions of the image. If they’re all the same, it could be that something else is embedded or that the overall RAM is exhausted.

Are you on the latest snap?

And yes, I can understand your frustration, but image processing requires RAM and unfortunately, these small computers don’t have much.  
Things will improves as ARM boards start to come with 4GB as standard, but that might take time.

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [December 9, 2016, 3:41pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/14 "2016-12-09T15:41:03Z")

</div>

> [@oparoz](#):
>
> But I wouldn’t recommend raising the limit on a Pi, it would be asking for trouble 😉

I reckon we could double it without fear of explosions. My box is comfortably sitting around 250MB/920MB available.

---

<div class="post-metadata">

**Author:** ![Raudn](https://help.nextcloud.com/letter_avatar/raudn/32/6_22734026db12803ebb3e059622ac3534.png) [@Raudn](https://help.nextcloud.com/u/Raudn)\
**Post date:** [December 18, 2016, 3:43pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/15 "2016-12-18T15:43:10Z")

</div>

same for mine, I also guess that doubling memory for PHP should be fine.

---

<div class="post-metadata">

**Author:** ![oparoz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oparoz/32/135_2.png) [@oparoz](https://help.nextcloud.com/u/oparoz)\
**Post date:** [December 23, 2016, 10:34am UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/16 "2016-12-23T10:34:46Z")

</div>

Here is why I think it won’t work by simply changing the limit…

4 PHP processes are running in parallel to generate thumbnails.  
At 128MB each, you’re using 512M RAM, leaving some for Apache and MySQL  
Now at 256MB, you’re using the full 1GB, which means that MySQL will crash.

So, same result, different reason :(.

The real solution is to make modifications to Gallery, making it possible to only generate 2 thumbnails in parallel via a configuration switch.

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [December 23, 2016, 12:09pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/17 "2016-12-23T12:09:27Z")

</div>

@oparoz are you the Gallery+ dev too? Would you be inclined to fork to a pi-friendly version alongside the current, or look to make modifications to mail source and leave it to users to enable & tweak that parallel setting?

---

<div class="post-metadata">

**Author:** ![oparoz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oparoz/32/135_2.png) [@oparoz](https://help.nextcloud.com/u/oparoz)\
**Post date:** [December 23, 2016, 12:43pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/18 "2016-12-23T12:43:36Z")

</div>

Yes, I’m the maintainer, but I’m not doing much with it atm due to lack of resources.  
I would be open to introduce such a setting because I just had to pick one value which might not be the best one for all hardware configs, so the plan was always to make it configurable.

I’ll accept PRs f you know someone who can help. I can give all the needed info.

---

<div class="post-metadata">

**Author:** ![JasonBayton](https://help.nextcloud.com/user_avatar/help.nextcloud.com/jasonbayton/32/297_2.png) [@JasonBayton](https://help.nextcloud.com/u/JasonBayton)\
**Post date:** [December 23, 2016, 12:57pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/19 "2016-12-23T12:57:18Z")

</div>

I’ll ask around.

Separately, any idea why there isn’t a download button in gallery view of each picture? Surely download is as important as delete (original gallery).

---

<div class="post-metadata">

**Author:** ![oparoz](https://help.nextcloud.com/user_avatar/help.nextcloud.com/oparoz/32/135_2.png) [@oparoz](https://help.nextcloud.com/u/oparoz)\
**Post date:** [December 23, 2016, 1:00pm UTC](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183/20 "2016-12-23T13:00:48Z")

</div>

That button is missing from the slideshow in Files, not Gallery. I just assumed it was redundant at the time, before it was hidden under the 3-dots menu.  
The plan is to re-enable it.

[Next page](https://help.nextcloud.com/t/nc-box-memory-exhausted/4183.md?page=2)
