Memory Leak In Mobile App Integration's Push Notification Service
The Problem
Memory leaks can be a frustrating issue for Home Assistant users, causing their instances to freeze randomly due to a lack of available memory. Recently, I encountered a similar problem with my Home Assistant instance, which would freeze randomly due to a memory leak. The memory usage would suddenly start to grow continuously, and then start to swap a lot, kill a lot of processes trying to free up memory, eventually giving up and freezing.
Identifying the Memory Leak
To identify the memory leak, I used the Profiler integration to log the object memory growth when the leak happened. The Profiler integration provided valuable insights into the memory usage of my Home Assistant instance. Here's what I found:
2025-04-23 02:30:34.875 CRITICAL (SyncWorker_46) [homeassistant.components.profiler] Memory Growth: [('cell', 1473089, 7307), ('tuple', 878774, 3724), ('function', 850181, 3654), ('PushChannel', 327059, 1824), ('_MIoTLanRequestData', 210054, 12)]
The output indicates that the PushChannel
object is growing significantly, which suggests that it might be the source of the memory leak. To further investigate, I dumped the PushChannel
object to log:
2025-04-23 23:08:44.809 CRITICAL (SyncWorker_9) [homeassistant.components.profiler] PushChannel object in memory: <homeassistant.components.mobile_app.push_notification.PushChannel object at 0xffff7aab77d0>
The output confirms that the PushChannel
object is indeed the culprit behind the memory leak.
Reloading Mobile App Integration's Config Entries
To resolve the memory leak, I created an automation that reloads all Mobile App integration's config entries when memory usage reaches 85%. The automation fired when the memory usage exceeded 85%, and the Mobile App integration reloaded successfully. Here's what happened:
The peak in the middle is where memory usage went above 85%, and the automation fired, Mobile App integration reloaded, and everything went back to normal.
Conclusion
Based on the investigation, it is highly likely that there is a memory leak in the Mobile App integration's push notification service, specifically with the PushChannel
object. The automation that reloads the Mobile App integration's config entries when memory usage reaches 85% has resolved the issue temporarily. However, a more permanent solution is required to fix the memory leak.
System Information
What version of Home Assistant Core has the issue?
2025.4.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
mobile_app
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might useful for us?
Additional information
No response
Recommendations
To resolve the memory leak, I recommend the following:
- Update to the latest version of Home Assistant Core: Ensure that you are running the latest version of Home Assistant Core, which may include bug fixes and improvements.
- Disable the Mobile App integration's push notification service: Temporarily disable the push notification service to see if it resolves the memory leak.
- Investigate the
PushChannel
object: Further investigate thePushChannel
object to identify the root cause of the memory leak. - Create a custom automation: Create a custom automation that reloads the Mobile App integration's config entries when memory usage reaches 85% to resolve the issue temporarily.
Q: What is a memory leak in Home Assistant?
A: A memory leak in Home Assistant occurs when the system fails to free up memory that is no longer in use, causing the memory usage to grow continuously. This can lead to a range of issues, including slow performance, crashes, and freezes.
Q: How do I identify a memory leak in Home Assistant?
A: To identify a memory leak in Home Assistant, you can use the Profiler integration to log the object memory growth when the leak happens. This will provide valuable insights into the memory usage of your Home Assistant instance.
Q: What is the PushChannel
object, and why is it causing a memory leak?
A: The PushChannel
object is a component of the Mobile App integration's push notification service. It appears to be the source of the memory leak, as it is growing significantly and causing the memory usage to increase.
Q: How can I resolve the memory leak in the Mobile App integration's push notification service?
A: To resolve the memory leak, you can try the following:
- Update to the latest version of Home Assistant Core: Ensure that you are running the latest version of Home Assistant Core, which may include bug fixes and improvements.
- Disable the Mobile App integration's push notification service: Temporarily disable the push notification service to see if it resolves the memory leak.
- Investigate the
PushChannel
object: Further investigate thePushChannel
object to identify the root cause of the memory leak. - Create a custom automation: Create a custom automation that reloads the Mobile App integration's config entries when memory usage reaches 85% to resolve the issue temporarily.
Q: What are the symptoms of a memory leak in Home Assistant?
A: The symptoms of a memory leak in Home Assistant can include:
- Slow performance
- Crashes
- Freezes
- Increased memory usage
- Swapping (using disk space to store memory)
Q: How can I prevent memory leaks in Home Assistant?
A: To prevent memory leaks in Home Assistant, you can:
- Regularly update to the latest version of Home Assistant Core
- Disable unused integrations and services
- Monitor memory usage and performance
- Use the Profiler integration to identify potential memory leaks
- Create custom automations to resolve memory leaks
Q: What should I do if I experience a memory leak in Home Assistant?
A: If you experience a memory leak in Home Assistant, you should:
- Try to identify the root cause of the memory leak
- Use the Profiler integration to log the object memory growth
- Create a custom automation to resolve the memory leak
- Contact Home Assistant support for further assistance
By following these FAQs, you can better understand memory leaks in Home Assistant and take steps to prevent and resolve them.