Why am i getting this error in my livekit cloud lo...
# ask-ai
a
Why am i getting this error in my livekit cloud logs What does it mean? {"message": "process memory usage is high", "level": "WARNING", "name": "livekit.agents", "memory_usage_mb": 509.55859375, "memory_warn_mb": 500, "memory_limit_mb": 0, "pid": 149, "job_id": "AJ_yg8WRwYqEQv3", "timestamp": "2025-10-02T050628.603954+00:00"}
t
Thanks for reaching out, David. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like the log message is letting you know that a process is using more memory than the warning threshold we've set (500 MB here), but it hasn’t yet reached the hard limit that would stop the process. This warning comes from the memory monitor task to gently alert you about the high memory usage. Here are some friendly suggestions to help you manage this: • Adjust Memory Thresholds: If you expect your workload to use more memory, you can increase the
memoryWarnMB
and
memoryLimitMB
values in the agent’s configuration. • Optimize Agent Code: Take a look at your code to spot any memory inefficiencies, like making sure unused resources are released or using streaming for handling large data. • Scale Resources: Double-check that your deployment environment has enough memory. For memory-heavy tasks, LiveKit suggests 4 cores and 8GB RAM per worker. • Monitor Concurrent Jobs: Try to limit how many memory-intensive jobs run at the same time on each worker to prevent overload. • Use Efficient Models: Consider optimizing your models for better runtime performance and lowering frame sampling rates or image resolution if you’re working on vision tasks. • Deploy on Adequate Infrastructure: Platforms like Kubernetes or LiveKit Cloud can give you better control over memory allocation, which might be helpful. Following these steps should make it easier for you to manage and resolve the high memory usage warning. If you need any more help, feel free to reach out—we’re here to support you! Sources: Deploying to custom environments | LiveKit Docs | README.md | Docs::Agents | livekit-agents/livekit/agents/ipc/inference_proc_executor.py | agents/src/ipc/supervised_proc.ts
a
Could this be caused my a large initial context when starting a session
t
Thanks for reaching out! Could you please help me understand a bit more about what you mean by 'large initial context'? Are you talking about a big chunk of data being loaded or processed right at the start of a session, like models, datasets, or other resources? Getting a clearer picture will really help us figure out if this might be causing the high memory usage warning you’re seeing. I’m here to help you through this!
a
By initial context i mean Chatcontext().add_message(role=, content=) My content is usually around 500k characters Also what is the hard limit
t
Thanks for reaching out! I understand that initializing a
ChatContext
with 500k characters might seem a bit overwhelming in terms of memory usage. Let me walk you through some important limits we have in place to help manage this: • Message Size Limit: Each message can only be up to 1024 characters long. So, a single message with 500k characters would actually be cut off. • Message Count Limit: A
ChatContext
can hold up to 40 messages. If there are more, the extras will be trimmed. These limits are here to protect your system from running out of resources. That said, working with large amounts of data—like splitting or handling those 500k characters—can still use more memory and might cause warnings. Hard Memory Limit: There’s a configurable hard memory limit per process. By default, it’s turned off (set to 0), but if you enable it and go over the limit, the process will stop. You can tweak this using the
memory_limit_mb
setting in your agent’s configuration. If you’re seeing memory warnings, it might help to optimize how you handle your data or increase the memory limits if your application really needs to work with large contexts. I’m here to help if you want to explore those options together! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | pkg/stats/monitor.go | LiveKit