* Add shortSummary field to review summary to be used for notifications * pull in current config version into default config * fix crash when dynamically adding cameras depending on where we are in the update loop, camera configs might not be updated yet and we are receiving detections already * add no tracked objects and icon to explore summary view * reset add camera wizard when closing and saving * don't flash no exports icon while loading * Improve handling of homekit config * Increase prompt tokens reservation * Adjust * Catch event not found object detection * Use thread lock for JinaV2 in onnxruntime * remove incorrect embeddings process from memray docs * only show transcribe button if audio event has video * apply aspect ratio and margin constraints to path overlay in detail stream on mobile improves a specific case where the overlay was not aligned with 4:3 cameras on mobile phones * show metadata title as tooltip on icon hover in detail stream --------- Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
5.2 KiB
id, title
| id | title |
|---|---|
| memory | Memory Troubleshooting |
Frigate includes built-in memory profiling using memray to help diagnose memory issues. This feature allows you to profile specific Frigate modules to identify memory leaks, excessive allocations, or other memory-related problems.
Enabling Memory Profiling
Memory profiling is controlled via the FRIGATE_MEMRAY_MODULES environment variable. Set it to a comma-separated list of module names you want to profile:
# docker-compose example
services:
frigate:
...
environment:
- FRIGATE_MEMRAY_MODULES=frigate.embeddings,frigate.capture
# docker run example
docker run -e FRIGATE_MEMRAY_MODULES="frigate.embeddings" \
...
--name frigate <frigate_image>
Module Names
Frigate processes are named using a module-based naming scheme. Common module names include:
frigate.review_segment_manager- Review segment processingfrigate.recording_manager- Recording managementfrigate.capture- Camera capture processes (all cameras with this module name)frigate.process- Camera processing/tracking (all cameras with this module name)frigate.output- Output processingfrigate.audio_manager- Audio processingfrigate.embeddings- Embeddings processing
You can also specify the full process name (including camera-specific identifiers) if you want to profile a specific camera:
FRIGATE_MEMRAY_MODULES=frigate.capture:front_door
When you specify a module name (e.g., frigate.capture), all processes with that module prefix will be profiled. For example, frigate.capture will profile all camera capture processes.
How It Works
-
Binary File Creation: When profiling is enabled, memray creates a binary file (
.bin) in/config/memray_reports/that is updated continuously in real-time as the process runs. -
Automatic HTML Generation: On normal process exit, Frigate automatically:
- Stops memray tracking
- Generates an HTML flamegraph report
- Saves it to
/config/memray_reports/<module_name>.html
-
Crash Recovery: If a process crashes (SIGKILL, segfault, etc.), the binary file is preserved with all data up to the crash point. You can manually generate the HTML report from the binary file.
Viewing Reports
Automatic Reports
After a process exits normally, you'll find HTML reports in /config/memray_reports/. Open these files in a web browser to view interactive flamegraphs showing memory usage patterns.
Manual Report Generation
If a process crashes or you want to generate a report from an existing binary file, you can manually create the HTML report:
- Run
memrayinside the Frigate container:
docker-compose exec frigate memray flamegraph /config/memray_reports/<module_name>.bin
# or
docker exec -it <container_name_or_id> memray flamegraph /config/memray_reports/<module_name>.bin
- You can also copy the
.binfile to the host and runmemraylocally if you have it installed:
docker cp <container_name_or_id>:/config/memray_reports/<module_name>.bin /tmp/
memray flamegraph /tmp/<module_name>.bin
Understanding the Reports
Memray flamegraphs show:
- Memory allocations over time: See where memory is being allocated in your code
- Call stacks: Understand the full call chain leading to allocations
- Memory hotspots: Identify functions or code paths that allocate the most memory
- Memory leaks: Spot patterns where memory is allocated but not freed
The interactive HTML reports allow you to:
- Zoom into specific time ranges
- Filter by function names
- View detailed allocation information
- Export data for further analysis
Best Practices
-
Profile During Issues: Enable profiling when you're experiencing memory issues, not all the time, as it adds some overhead.
-
Profile Specific Modules: Instead of profiling everything, focus on the modules you suspect are causing issues.
-
Let Processes Run: Allow processes to run for a meaningful duration to capture representative memory usage patterns.
-
Check Binary Files: If HTML reports aren't generated automatically (e.g., after a crash), check for
.binfiles in/config/memray_reports/and generate reports manually. -
Compare Reports: Generate reports at different times to compare memory usage patterns and identify trends.
Troubleshooting
No Reports Generated
- Check that the environment variable is set correctly
- Verify the module name matches exactly (case-sensitive)
- Check logs for memray-related errors
- Ensure
/config/memray_reports/directory exists and is writable
Process Crashed Before Report Generation
- Look for
.binfiles in/config/memray_reports/ - Manually generate HTML reports using:
memray flamegraph <file>.bin - The binary file contains all data up to the crash point
Reports Show No Data
- Ensure the process ran long enough to generate meaningful data
- Check that memray is properly installed (included by default in Frigate)
- Verify the process actually started and ran (check process logs)
For more information about memray and interpreting reports, see the official memray documentation.