question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nginx error 12: Cannot allocate memory

See original GitHub issue

Describe the bug Frigate 9.0+ is failing to start due to an nginx related memory error on my Google Coral Dev Board. Frigate 8.4 runs fine. This is my first attempt at frigate so I apologize if this was caused by a minor oversight.

Version of frigate frigate:0.9.0-rc2-aarch64

Config file

mqtt:
  host: <ANON_HOST_IP>
  port: 1883
  topic_prefix: frigate
detectors:
  coral:
    type: edgetpu
    device: ''
cameras:
  front_door:
    ffmpeg:
      inputs:
        - path: rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 360
      fps: 5
      enabled: True
      max_disappeared: 25
    motion:
      mask: 0,0,238,0,236,25,0,25
    record:
      enabled: False
      retain_days: 0
      events:
        enabled: True
        pre_capture: 5
        post_capture: 5
        objects:
          - person
        required_zones: []
        retain:
          default: 10
          objects:
            person: 15
    rtmp:
      enabled: False
    live:
      height: 360
      quality: 8
    objects:
      track:
        - person

Frigate container logs

fm@coral:~/home$ docker-compose up
Starting frigate ... done
Attaching to frigate
frigate    | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
frigate    | [s6-init] ensuring user provided files have correct perms...exited 0.
frigate    | [fix-attrs.d] applying ownership & permissions fixes...
frigate    | [fix-attrs.d] done.
frigate    | [cont-init.d] executing container initialization scripts...
frigate    | [cont-init.d] done.
frigate    | [services.d] starting services
frigate    | [services.d] done.
frigate    | nginx: [alert] mmap(MAP_ANON|MAP_SHARED, 536870912) failed (12: Cannot allocate memory)
frigate    | nginx: [alert] munmap(FFFFFFFFFFFFFFFF, 536870912) failed (22: Invalid argument)
frigate    | [cont-finish.d] executing container finish scripts...
frigate    | [cont-finish.d] done.
frigate    | [s6-finish] waiting for services.
frigate    | [s6-finish] sending all processes the TERM signal.
frigate    | [s6-finish] sending all processes the KILL signal and exiting.

FFprobe from camera

 ffprobe rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2
ffprobe version 3.4.8-0ubuntu0.2 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix=/usr --extra-version=0ubuntu0.2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, rtsp, from 'rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_RTSP_IP}:554/stream2':
  Metadata:
    title           : Session streamed by "TP-LINK RTSP Server"
    comment         : stream2
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 15 fps, 15 tbr, 90k tbn, 30 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, 1 channels, s16, 64 kb/s

Computer Hardware

  • OS: Mendel Linux (Debian 8)
  • Install method: Docker Compose
  • Coral Version: Coral Dev Board
  • Network Setup: Ethernet

Camera Info:

  • Manufacturer: TP-Link
  • Model: Tapo C100 (also tested with C200)
  • Resolution: Using 640x360 stream
  • FPS: 5

Additional context I am starting Frigate from a docker container using the following docker-compose config:

version: "3.9"
services:
  frigate:
    container_name: frigate
    image: blakeblackshear/frigate:0.9.0-rc2-aarch64
    privileged: true 
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - $FRIGATE_DATA_PATH/config.yml:/config/config.yml:ro
      - $FRIGATE_MEDIA_PATH:/media/frigate
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP feeds
      - "1883:1883"
    environment:
      FRIGATE_RTSP_PASSWORD: $FRIGATE_RTSP_PASSWORD
      FRIGATE_RTSP_USER: $FRIGATE_RTSP_USER

My /etc/docker/daemon.json file is as follows:

{
    "default-shm-size": "256M"
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ozettcommented, Nov 9, 2021

maybe the memory is allocated by VOD on the coral-dev-board since 0.9x. and maybe it oculd be configured to give up that allocation

0reactions
nickroutcommented, Jan 31, 2022

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot allocate memory error in nginx with huge number of ...
Nginx is set up on simple AWS t2.small instance with Ubuntu 16.04. It has 1GB of RAM and I see (with free -m...
Read more >
failed (12: Cannot allocate memory) while sending mp4 to client
Thanks, the problem seems to be clear enough. It looks like the file has invalid metadata and nginx isn't able to handle this...
Read more >
Linux – NGINX and failed (12: Cannot allocate memory)
I looked at the nginx error logs and found that it was trying to serve the media from /var/django/myproject/site_media/site_media instead of /var/django/ ...
Read more >
Cannot allocate memory error in nginx with ... - Stack Overflow
Nginx is set up on simple AWS t2.small instance with Ubuntu 16.04. It has 1GB of RAM and I see (with free -m...
Read more >
posix_memalign(16, 16384) failed (12 ... - nginx@nginx.org
posix_memalign(16, 16384) failed (12: Cannot allocate memory). JohnCarne ... Tweaks added 16/09/2016 for issue investigation on pisix error in nginx
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found