esp8266_milight_hub: Memory leak - causes settings to be randomly cleared
Describe the bug
After restore settings I see all the information. But after a while everything is gone in WebUI, strange enough… everything is still working inside HA to control the lights
Steps to reproduce
Restore settings, after while goto the WebGUI and everything is gone again.
Expected behavior
After restore all settings keep in memory.
Additional info
I don’t use anymore device name because that gives some issues as well.
Firmware version
1.10.5 (nodemcuv2)
Output of http://milight-hub.local/about: When WebGUI is empty
{"firmware":"milight-hub","version":"1.10.5","ip_address":"192.168.xxx.xxx","reset_reason":"Software/System restart","variant":"nodemcuv2","free_heap":6616,"arduino_version":"2_4_2","queue_stats":{"length":0,"dropped_packets":0}}
Output of http://milight-hub.local/about: When WebGUI is normal
{"firmware":"milight-hub","version":"1.10.5","ip_address":"192.168.xxx.xxx","reset_reason":"Software/System restart","variant":"nodemcuv2","free_heap":16016,"arduino_version":"2_4_2","queue_stats":{"length":0,"dropped_packets":0}}
Output of http://milight-hub.local/settings When WebGUI is empty
{}
Output of http://milight-hub.local/settings When WebGUI is normal
{"admin_username":"","admin_password":"","ce_pin":16,"csn_pin":15,"reset_pin":0,"led_pin":-2,"radio_interface_type":"nRF24","packet_repeats":50,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"192.168.xxx.xxx:1883","mqtt_username":"USERNAME","mqtt_password":"PASSWORD","mqtt_topic_pattern":"milight/:device_id/:device_type/:group_id","mqtt_update_topic_pattern":"milight/updates/:hex_device_id/:device_type/:group_id","mqtt_state_topic_pattern":"milight/states/:hex_device_id/:device_type/:group_id","mqtt_client_status_topic":"milight/client_status","simple_mqtt_client_status":true,"discovery_port":48899,"listen_repeats":0,"state_flush_interval":100,"mqtt_state_rate_limit":500,"packet_repeat_throttle_sensitivity":50,"packet_repeat_throttle_threshold":500,"packet_repeat_minimum":50,"enable_automatic_mode_switching":false,"led_mode_wifi_config":"Fast toggle","led_mode_wifi_failed":"Fast blip","led_mode_operating":"Slow toggle","led_mode_packet":"Fast blip","led_mode_packet_count":4,"hostname":"MilightHub","rf24_power_level":"MAX","rf24_listen_channel":"LOW","wifi_static_ip":"192.68.xxx.xxx","wifi_static_ip_gateway":"192.168.xxx.xxx","wifi_static_ip_netmask":"255.255.255.0","packet_repeats_per_loop":50,"home_assistant_discovery_prefix":"","wifi_mode":"n","default_transition_period":500,"rf24_channels":["LOW","MID","HIGH"],"device_ids":[43681,43682,43683,43684,43690,43691,43692,43693,43694,43695,43706,43707],"gateway_configs":[],"group_state_fields":["state","status","brightness","level","hue","saturation","color","mode","kelvin","color_temp","bulb_mode","computed_color","effect","device_id","group_id","device_type"],"group_id_aliases":{}}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 29 (21 by maintainers)
That’s very helpful, thanks. If we look at the color transitions, we see this:
Which means it’s trying to transition from a color to itself. That’s why the period is enormous as well (it’s the maximum value of a signed integer).
I think the fix here is to just change this:
https://github.com/sidoh/esp8266_milight_hub/blob/master/lib/Transitions/ColorTransition.cpp#L136
to
But I did 😉
Guys, I apologize for the lack of progress on this issue. Fixing this sort of thing takes a level of time and energy that I’ve unfortunately not had to give this project in a while.
As a really shitty bandaid – I expect that using the setting to have the hub restart itself every ~day would at least stop the settings from clearing themselves.
Also worth mentioning: this memory leak has been around for ages – ever since state tracking was introduced. Only seems to appear with a large number of groups (I’m testing with 20 devices and 8 groups). Unclear if this is the problem given it’s an older bug, but: