warden
warden copied to clipboard
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.
The same problem happens with elasticsearch container
for reference, here is other discussion: https://github.com/docker/for-mac/issues/5204
Reading around a bit it would seem it is necessary to replace the images with specific images for arm architecture. At this point I think it would be necessary to follow what k4emic has been said here:
https://github.com/davidalger/warden/pull/317
@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.
great! for php-fpm what are specific about warden php images? do they have any particular config? If we can get some general config, maybe we might be able to have a working stack for m1.
Hello, I have the same issue. Could you tell me how to fix it? I tried to edit .env file and change elasticsearch version to 7.8/7.12. My configuration for elastisearch is:
elasticsearch:
environment:
ES_JAVA_OPTS: -Xms64m -Xmx512m
discovery.type: single-node
xpack.security.enabled: "false"
hostname: exampleproject-elasticsearch
image: docker.io/wardenenv/elasticsearch:7.8
labels:
traefik.enable: "true"
traefik.http.routers.exampleproject-elasticsearch.rule: Host(`elasticsearch.exampleproject.test`)
traefik.http.routers.exampleproject-elasticsearch.tls: "true"
traefik.http.services.exampleproject-elasticsearch.loadbalancer.server.port: '9200'
volumes:
- esdata:/usr/share/elasticsearch/data:rw
But this problem still occurs. Could you help me to fix it?
Hello, I have the same issue. Could you tell me how to fix it? I tried to edit .env file and change elasticsearch version to 7.8/7.12. My configuration for elastisearch is:
elasticsearch: environment: ES_JAVA_OPTS: -Xms64m -Xmx512m discovery.type: single-node xpack.security.enabled: "false" hostname: exampleproject-elasticsearch image: docker.io/wardenenv/elasticsearch:7.8 labels: traefik.enable: "true" traefik.http.routers.exampleproject-elasticsearch.rule: Host(`elasticsearch.exampleproject.test`) traefik.http.routers.exampleproject-elasticsearch.tls: "true" traefik.http.services.exampleproject-elasticsearch.loadbalancer.server.port: '9200' volumes: - esdata:/usr/share/elasticsearch/data:rw
But this problem still occurs. Could you help me to fix it?
You have to change the image, to:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
but how? in .env?
environment:
ES_JAVA_OPTS: -Xms64m -Xmx512m
discovery.type: single-node
xpack.security.enabled: "false"
hostname: exampleproject-elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
labels:
traefik.enable: "true"
traefik.http.routers.exampleproject-elasticsearch.rule: Host(`elasticsearch.exampleproject.test`)
traefik.http.routers.exampleproject-elasticsearch.tls: "true"
traefik.http.services.exampleproject-elasticsearch.loadbalancer.server.port: '9200'
volumes:
- esdata:/usr/share/elasticsearch/data:rw
Ok, but what exactly do I need to edit?
@webphpprojects
elasticsearch:
environment:
ES_JAVA_OPTS: -Xms64m -Xmx512m
discovery.type: single-node
xpack.security.enabled: "false"
hostname: exampleproject-elasticsearch
- image: docker.io/wardenenv/elasticsearch:7.8
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
labels:
traefik.enable: "true"
traefik.http.routers.exampleproject-elasticsearch.rule: Host(`elasticsearch.exampleproject.test`)
traefik.http.routers.exampleproject-elasticsearch.tls: "true"
traefik.http.services.exampleproject-elasticsearch.loadbalancer.server.port: '9200'
volumes:
- esdata:/usr/share/elasticsearch/data:rw
Ok, maybe my question was not precise enough. Where I can find the file I have to edit? I cannot find it in project folder even in .warden directory.
I see this in docs: https://docs.warden.dev/environments/customizing.html#docker-specific-customizations But I don't have .warden directory in my project
.warden directory is in your root folder when you open the terminal.
Yes, I see this directory, but I don't see there warden-env.yml
@webphpprojects
/opt/homebrew/Cellar/warden/0.10.2/environments/includes
@zcuric Thank you :)
What do I need to do after changing the proper file? I did
warden svc restart
and
warden env up -d
but the problem still occurs.
I find the solution. I switched to composer 2 and this problem does not occur.
Today I wanted to finish magento 2 installation and have this error:
bin/magento cache:clean
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
PHP Fatal error: Out of memory (allocated 64573440) (tried to allocate 5328896 bytes) in /var/www/html/vendor/colinmollenhour/credis/Client.php on line 1161
Fatal error: Out of memory (allocated 64573440) (tried to allocate 5328896 bytes) in /var/www/html/vendor/colinmollenhour/credis/Client.php on line 1161
How can I fix it?
@webphpprojects you can't, not until warden devs update docker images to be compatible with ARM. Because if you read issue from the beginning, we only found solution for elasticsearch.
OK, but in my case changing elasticsearch image did not solve a problem. I see you are using warden 0.10.2. In my case it's 0.11. Maybe I should switch to older version?
@webphpprojects That won't fix your problem. It fixes elasticsearch part of the problem, but php memory issue is up to warden devs.
So I have to wait for a fix, right?
@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).
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
let's keep it open
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?
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This is definitely still active and valid. :)
Hi @drpayyne,
Can we re-use your images just by replacing WARDEN_IMAGE_REPOSITORY
with your image prefix? Are there any other modifications required?
I doubt that it'll work right OOTB by just using that tag since my images are still "in-beta" as far as I'm concerned so I've tag names which aren't a direct substitution to existing tag names. For example - I have tags ending in -deb
to show that the images are Debian based. That said, I think it'd be good to map it directly after verifying that there is nothing else blocking it, @ihor-sviziev.
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:
- 🟡 Varnish is not working - https://github.com/davidalger/warden/pull/484
- 🟡 Redis, MariaDB, RabbitMQ - https://github.com/davidalger/warden/issues/485 I think we can switch to official images as we don't have any modifications and the official ones does has support
- 🟡 Nginx - works fine in emulation, TODO
- ❌ Php-FPM + xdebug - works very slow, TODO
- ❌ Elasticsearch - works very slow, https://github.com/davidalger/warden/pull/488
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