High memory usage of a Kirby site? How much memory is recommended?

Hey there,

We currently have problems with insufficient memory on one of our webhosters.

The errors occur on the generation of the media images especially when a lot of images are generated at once (understandable since we generate two different sizes per bitmap), but they also happen in the panel on pages that don’t have any images at all. The error displayed is “The JSON response of the API could not be parsed” since one or more API calls return 500.

The panel holds about 80 images with 26mb in total that are spread across multiple pages. Half of those images are JPEGs with a size of about 1920x1080px, the other half is small SVG and we also got about 3 small PNGs.

Our webhoster offers 2gb of RAM and says that those are completely filled up when the errors occur However on our staging environment (which isn’t a managed server) we measure a usage of about 450mb on full load. We are measuring that with htop and maybe htop doesn’t display peaks?

So I got a few questions regarding that:

  • How much RAM does a regular Kirby site need?
  • Do you have an idea where the differences in RAM usage comes from? Are our measurements wrong?
  • Do videos in the panel add a lot to the RAM usage since those aren’t resized and don’t have thumbnails?


TBH 80 images at 26MB in total is about 350kB/image on average. That’s nothing Kirby should not be able to handle. AFAIK video’s don’t take up much RAM in panel neither as they aren’t rendered.

I did have issues with seemlingly small png’s in the past because of transparency combined with a very high dpi. This eats up RAM very fast.

The weird thing is that you say it also happens on pages without images. This makes me think the image resizes arent the culprit here tbh. Have you checked the error log? Do you do other “weird” things in the panel (hooks etc)?

Kirby doesn’t really need a lot of resources. And resized versions of images are only created once for every new image and only those thumbs are created that are actually needed (in the Panel or the frontend).

As @bvdputte already wrote, 80 images is not a big deal at all.

Are you making excessive calls to $site->index() all over the place maybe? That would explain why pages without any images are affected.

What plugins are you using?

Thank you for your fast replies!

What plugins are you using?

The plugins that we are using are:

  • api & auth (both custom built, but those only add api routes)
  • autoresize
  • gallery (from the starterkit)

Disabling those plugins didn’t help though.

Are you making excessive calls to $site->index() all over the place maybe? That would explain why pages without any images are affected.

We don’t use that function at all.

Have you checked the error log?

The Apache error log only says this (I removed the domain and IP):
[Fri Mar 05 15:25:25.235881 2021] [:error] [pid 10166:tid 47025806472960] (12)Cannot allocate memory: [client] couldn't create child process: /usr/sbin/suphp for /home2/kd00000/public_html/index.php, referer: https://domain.tld/

do you do other “weird” things in the panel (hooks etc)?

No. We had a few hooks active regarding account creation/editing, but those have already been removed.

Yesterday we removed various unneeded PHP Extensions and shrunk the images down a bit and that seems to have bettered the situation. In addition to that we removed the pages sections from our pages (since they don’t have subpages and those calls sometimes threw 500s as well).

The panel threw that error almost every time before that and only throws it about 1/10 times now. RAM usage is still at 100% though.

What is the php memory limit set to in php.ini?

It’s set to 128M but we already had that quite a lot higher and still experienced that problem.

Are you (or your hoster) really using suPHP?

The php info says:

Server API: CGI/FastCGI

So i guess that it does. This error also doesn’t happen on every pageview.