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

[teleinfo] Fix memory leak #9724

Merged
merged 3 commits into from Jan 13, 2021
Merged

Conversation

olivierkeke
Copy link
Contributor

Resolve #9546.

This PR prevents the ThingHandler from registering more than once to the bridge event when a bridgeStatusChanged is triggered.

@olivierkeke olivierkeke changed the title Fix memory leakPrevent from adding the same listener twice [teleinfo] Fix memory leakPrevent from adding the same listener twice Jan 6, 2021
@olivierkeke olivierkeke changed the title [teleinfo] Fix memory leakPrevent from adding the same listener twice [teleinfo] Fix memory leak Jan 6, 2021
@cpmeister cpmeister added the bug An unexpected problem or unintended behavior of an add-on label Jan 6, 2021
Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
@olivierkeke
Copy link
Contributor Author

@cpmeister Thank you for the tip! I've pushed a new version of the fix, can you check?

if (bridgeStatusInfo.getStatus() != ThingStatus.ONLINE) {
if (controllerHandler != null) {
controllerHandler.removeListener(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make sure that this gets called when the TeleinfoAbstractElectricityMeterHandler is disposed as well.
Looks like you need to override the dispose method to get that done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
@wborn wborn added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jan 10, 2021
@cpmeister cpmeister merged commit 4e73b05 into openhab:main Jan 13, 2021
@cpmeister cpmeister added this to the 3.1 milestone Jan 13, 2021
nowaterman pushed a commit to nowaterman/openhab-addons that referenced this pull request Jan 19, 2021
* Use set instead list to avoid duplicate listeners
* Remove from listeners when bridge is not ONLINE
* Unsubscribe from bridge handler events when thing handler is disposed
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
* Use set instead list to avoid duplicate listeners
* Remove from listeners when bridge is not ONLINE
* Unsubscribe from bridge handler events when thing handler is disposed

Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
* Use set instead list to avoid duplicate listeners
* Remove from listeners when bridge is not ONLINE
* Unsubscribe from bridge handler events when thing handler is disposed

Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* Use set instead list to avoid duplicate listeners
* Remove from listeners when bridge is not ONLINE
* Unsubscribe from bridge handler events when thing handler is disposed

Signed-off-by: Olivier Marceau <hollysaiqs@marceau.ovh>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[teleinfo] Memory leak
3 participants