Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Memory leak #484

Open
2 tasks done
tlanfer opened this issue Nov 27, 2024 · 6 comments
Open
2 tasks done

[Bug]: Memory leak #484

tlanfer opened this issue Nov 27, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@tlanfer
Copy link

tlanfer commented Nov 27, 2024

Requirements

  • I checked the troubleshooting section in the README to verify that I have the latest TrashCard version.
  • I did a search to see if there is a similar issue or if a pull request is open.

Current Behavior

I'm running fully kiosk browser with a home assistant dashboard on a lenovo tablet in the hallway, showing some useful information like the trash collection schedule. I noticed regularly, the app would close. looking at the "free memory" statistics from fully kiosk, it showed that the memory would get eaten up rather quickly.
Comparing the dashboard with another tablet i am using, the main difference was the hassio-trash-card.
Watching a the builtin chrome task manager on my desktop machine, showing the same dashboard, i can watch the memory footprint grow by a few megabytes every few minutes.

Removing the trash card makes this behavior stop.
I attached a screenshot of the statistic for "free memory". The left half was when i still had the trash card on that dashboard. the gaps are when the app was closed because android killed it for using too much memory. the right half is from after i removed the card from the dashboard.

Expected Behavior

I expected the memory to be roughly stable.
I have not found the time yet to do more experiments to find out if something specific in my configuration causes this.

Steps To Reproduce

This is my card config:

event_grouping: true
drop_todayevents_from: "10:00:00"
next_days: 14
pattern:
  - icon: mdi:flower
    color: brown
    type: organic
    label: Bioabfall
    pattern: Bioabfall
  - icon: mdi:newspaper
    color: blue
    type: paper
    label: Altpapier
    pattern: Altpapier
  - icon: mdi:recycle-variant
    color: amber
    type: recycle
    label: Gelbe Tonne
    pattern: Gelbe Tonne
  - icon: mdi:trash-can-outline
    color: grey
    type: waste
    label: Restmüll
    pattern: Restmüll
  - icon: mdi:dump-truck
    color: purple
    type: others
day_style: counter
alignment_style: left
items_per_row: 3
refresh_rate: 60
with_label: true
layout: vertical
type: custom:trash-card
entities:
  - calendar.mull
layout_options:
  grid_columns: full
  grid_rows: 2
filter_events: true
hide_time_range: true
use_summary: false
full_size: false

The calendar is coming in through the google calendar integration

Context

YAML state

Environment

- Browser: Chrome
- HA Version: 2024.11.0
- TrashCard: 2.4.4

Debug data

[{"message":"timezone","data":"+01:00"},{"message":"calendar data","data":[{"start":{"dateTime":"2024-11-27T07:00:00+01:00"},"end":{"dateTime":"2024-11-27T07:30:00+01:00"},"summary":"Altpapier","description":"Altpapier","location":"Fritz-Reuter-Straße, Gescher","uid":"7d2e6118-f504-430c-b84e-ceec4f972a78","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},{"start":{"dateTime":"2024-11-28T07:00:00+01:00"},"end":{"dateTime":"2024-11-28T07:30:00+01:00"},"summary":"Bioabfall","description":"Bioabfall","location":"Fritz-Reuter-Straße, Gescher","uid":"88530081-f716-4930-82ea-99b27ca6aa10","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},{"start":{"dateTime":"2024-11-28T07:00:00+01:00"},"end":{"dateTime":"2024-11-28T07:30:00+01:00"},"summary":"Gelbe Tonne","description":"Gelbe Tonne","location":"Fritz-Reuter-Straße, Gescher","uid":"07b73300-37e9-4306-81d8-c74fd2911f01","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},{"start":{"dateTime":"2024-12-11T07:00:00+01:00"},"end":{"dateTime":"2024-12-11T07:30:00+01:00"},"summary":"Restmüll 2W","description":"Restmüll 2W","location":"Fritz-Reuter-Straße, Gescher","uid":"e1deb64e-e46a-41c5-b809-0ca89a61778c","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}]},{"message":"normaliseEvents","data":[{"date":{"start":"2024-11-27T06:00:00.000Z","end":"2024-11-27T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Altpapier","description":"Altpapier","location":"Fritz-Reuter-Straße, Gescher","uid":"7d2e6118-f504-430c-b84e-ceec4f972a78","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}},{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Bioabfall","description":"Bioabfall","location":"Fritz-Reuter-Straße, Gescher","uid":"88530081-f716-4930-82ea-99b27ca6aa10","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}},{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Gelbe Tonne","description":"Gelbe Tonne","location":"Fritz-Reuter-Straße, Gescher","uid":"07b73300-37e9-4306-81d8-c74fd2911f01","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}},{"date":{"start":"2024-12-11T06:00:00.000Z","end":"2024-12-11T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Restmüll 2W","description":"Restmüll 2W","location":"Fritz-Reuter-Straße, Gescher","uid":"e1deb64e-e46a-41c5-b809-0ca89a61778c","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}}]},{"message":"dropAfter","data":true},{"message":"now","data":"2024-11-27T21:03:25.718Z"},{"message":"activeElements","data":[{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Bioabfall","description":"Bioabfall","location":"Fritz-Reuter-Straße, Gescher","uid":"88530081-f716-4930-82ea-99b27ca6aa10","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}},{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Gelbe Tonne","description":"Gelbe Tonne","location":"Fritz-Reuter-Straße, Gescher","uid":"07b73300-37e9-4306-81d8-c74fd2911f01","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}},{"date":{"start":"2024-12-11T06:00:00.000Z","end":"2024-12-11T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Restmüll 2W","description":"Restmüll 2W","location":"Fritz-Reuter-Straße, Gescher","uid":"e1deb64e-e46a-41c5-b809-0ca89a61778c","recurrence_id":null,"rrule":null,"entity":"calendar.mull"}}]},{"message":"eventsToItems","data":[{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Bioabfall","description":"Bioabfall","location":"Fritz-Reuter-Straße, Gescher","uid":"88530081-f716-4930-82ea-99b27ca6aa10","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},"icon":"mdi:flower","color":"brown","type":"organic","label":"Bioabfall","pattern":"Bioabfall","idx":0},{"date":{"start":"2024-11-28T06:00:00.000Z","end":"2024-11-28T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Gelbe Tonne","description":"Gelbe Tonne","location":"Fritz-Reuter-Straße, Gescher","uid":"07b73300-37e9-4306-81d8-c74fd2911f01","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},"icon":"mdi:recycle-variant","color":"amber","type":"recycle","label":"Gelbe Tonne","pattern":"Gelbe Tonne","idx":2},{"date":{"start":"2024-12-11T06:00:00.000Z","end":"2024-12-11T06:30:00.000Z"},"isWholeDayEvent":false,"content":{"summary":"Restmüll 2W","description":"Restmüll 2W","location":"Fritz-Reuter-Straße, Gescher","uid":"e1deb64e-e46a-41c5-b809-0ca89a61778c","recurrence_id":null,"rrule":null,"entity":"calendar.mull"},"icon":"mdi:trash-can-outline","color":"grey","type":"waste","label":"Restmüll","pattern":"Restmüll","idx":3}]}]

Anything else?

image

@tlanfer tlanfer added the bug Something isn't working label Nov 27, 2024
@tlanfer
Copy link
Author

tlanfer commented Nov 27, 2024

Alright i checked for other issues of the same problem earlier today, and in the time between me checking earlier and me creating the issue just now, someone created #483

@TheBassfly
Copy link

Thank you for your investigation

Maybe this is also the origin of my issue.

@idaho
Copy link
Owner

idaho commented Nov 28, 2024

Hey, I haven't had time to dive deep into the details, but I think this is related to an issue where all displayed elements are re-rendered even if there is no ‘change’. This happens when something in the hass object changes. I'm not 100% sure, but since an update to the home assistant, I get a time update 2 times a minute, so the cards were forced to re-render because there was a change. Watching the hass object for changes is required when you change the theme, language or dark/light mode. The current fix now looks more closely at the changes and whether or not they contain changes relevant to the TrashCard. This should greatly reduce the rendering time. I have also changed the implementation of how the containers are initialised so that only the relevant information, such as time etc., is updated instead of the entire cards.
I think this will even solve the memory leak issue, if not i will have closer look. Please let me know if the new release (2.4.5) will solve the issue or not.

@TheBassfly
Copy link

Hey, I haven't had time to dive deep into the details, but I think this is related to an issue where all displayed elements are re-rendered even if there is no ‘change’. This happens when something in the hass object changes. I'm not 100% sure, but since an update to the home assistant, I get a time update 2 times a minute, so the cards were forced to re-render because there was a change. Watching the hass object for changes is required when you change the theme, language or dark/light mode. The current fix now looks more closely at the changes and whether or not they contain changes relevant to the TrashCard. This should greatly reduce the rendering time. I have also changed the implementation of how the containers are initialised so that only the relevant information, such as time etc., is updated instead of the entire cards. I think this will even solve the memory leak issue, if not i will have closer look. Please let me know if the new release (2.4.5) will solve the issue or not.

Thanks for the fix.

I'm just waiting for it to popup in HACS.

A workaround otherwise is to use v. 2.4.0. This also looks stable.

@tlanfer
Copy link
Author

tlanfer commented Nov 28, 2024

A quick test on my desktop looks good. I just added the card back on my tablets dashboard, and will report back soon if the memory usage is stable.

@nexeck
Copy link

nexeck commented Dec 1, 2024

Crashed again for me with v2.4.5, not sure how long it took. But after removing the card again it stopped crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants