warden: mmap() Cannot allocate memory - memory leak for php and elasticsearch on Apple M1

Hi i get an error when i try to perform a simple bin/magento setup:upgrade inside php-fpm. The error is:

mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 70668288) (tried to allocate 5131192 bytes) in /var/www/html/vendor/colinmollenhour/cache-backend-file/File.php on line 202
Fatal error: Out of memory (allocated 70668288) (tried to allocate 5131192 bytes) in /var/www/html/vendor/colinmollenhour/cache-backend-file/File.php on line 202

I’ve already checked and Docker is set to use 8GB of RAM and 2GB of Swap. I checked the memory limit configuration and it is set to 2GB. I tried increasing it to 4 but the error didn’t change.

Same project with same config works correctly on Old mac intel.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 14
  • Comments: 36 (8 by maintainers)

Most upvoted comments

Note: as a temporary workaround, you can use Debain-based php-fpm images from @drpayyne by creating .warden/warden-env.darwin.yml file with the following content:

version: "3.5"
services:
  php-debug:
    image: ghcr.io/drpayyne/warden-php-m2-xdebug3:${PHP_VERSION}-deb
  php-fpm:
    image: ghcr.io/drpayyne/warden-php-m2:${PHP_VERSION}-deb

Update after https://github.com/davidalger/warden/pull/505: Global services:

  • ✅ Portainer already supports ARM64
  • ✅ Traefik already supports ARM64
  • ✅ Mailhog already supports ARM64 https://github.com/davidalger/warden/pull/505
  • 🟡 DNSmasq - works fine in emulation, TODO
  • 🟡 SSH tunnel - works fine in emulation, TODO

Mandatory parts for M2 projects:

Optional parts for M2 projects (didn’t check the status yet):

@antoniocarboni Regarding eleasticsearch I’ve manage to fix it by using offical elasticsearch image: https://github.com/davidalger/warden/blob/develop/environments/includes/elasticsearch.base.yml#L5

image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0

To fix this memory leak for php arm 64 versions of warden php-fpm imagens needs to be published.

PHP Arm64 images are available in beta: https://github.com/orgs/wardenenv/discussions/616

@Vitaliy-Lazarev I can recommend switching from Warden to Den (fork of Warden), which fully supports Apple Silicon CPUs https://github.com/swiftotter/den/

Ok. So I’m working on adding arm64 support for all the possible images (for now M2 projects only).

The status is following:

Global services:

  • ✅ Portainer already supports ARM64
  • ✅ Traefik already supports ARM64
  • 🟡 DNSmasq - works fine in emulation, TODO
  • 🟡 Mailhog - works fine in emulation, TODO
  • 🟡 SSH tunnel - works fine in emulation, TODO

Mandatory parts for M2 projects:

Optional parts for M2 projects (didn’t check status yet):

  • blackfire - TODO
  • allure - TODO
  • selenium + debug - TODO
  • split sales - TODO
  • split checkout - TODO
  • test db - TODO
  • magepack - TODO

This is still relevant and will be until Warden’s PHP images have ARM alternatives. I’m currently trying to rebuild the necessary PHP packages from Remi’s repository for as ARM versions, but need some assistance here. Does anyone have experience building RPMs with/without Mock? It’s critical to get this running since Remi does not have plans to publish ARM packages any time soon as he doesn’t have the necessary hardware. @davidalger, any thoughts?

@zcuric I made some research and found this topic and comment: https://github.com/markshust/docker-magento/issues/396#issuecomment-776854665 I hope it is useful for fixing this issue (I will check also).

The same problem happens with elasticsearch container

for reference, here is other discussion: https://github.com/docker/for-mac/issues/5204