Skip to content

Dispose the devices the adapter creates for its own event replay - #87

Open
Kinchul wants to merge 1 commit into
SuessLabs:developfrom
fiveco:vk/dispose-replayed-devices
Open

Dispose the devices the adapter creates for its own event replay#87
Kinchul wants to merge 1 commit into
SuessLabs:developfrom
fiveco:vk/dispose-replayed-devices

Conversation

@Kinchul

@Kinchul Kinchul commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Details

Mostly documentation, plus one small fix.

Every Device registers a D-Bus match rule in Device.CreateAsync, and that rule is released only when the Device is disposed. A connection is limited to max_match_rules_per_connection (2048 by default), so a consumer that discards the devices it receives eventually exhausts the limit and BlueZ calls start failing.

Device is IDisposable, but nothing stated that the devices delivered by DeviceFound and returned by GetDevicesAsync, GetDeviceAsync and WatchDevicesAddedAsync belong to the caller. This documents it on all four. We spent a long time tracking that down in #19, where the measurements are.

The one code change: TrackDeviceForConnection left its Device undisposed when tracking failed after creation. The catch releases the reserved slot, so nothing else can reach that device afterwards.

No API or behaviour change.

@Kinchul
Kinchul force-pushed the vk/dispose-replayed-devices branch from 5301681 to d51f69f Compare August 18, 2026 10:52
@Kinchul Kinchul changed the title Share one Device per object path so match rules stop accumulating Dispose the devices the adapter creates for its own event replay Aug 18, 2026
@Kinchul
Kinchul force-pushed the vk/dispose-replayed-devices branch 2 times, most recently from 009ee7c to 0b334d0 Compare August 18, 2026 12:26
@Kinchul
Kinchul marked this pull request as ready for review August 18, 2026 12:31
@DamianSuess DamianSuess self-assigned this Aug 28, 2026
@DamianSuess DamianSuess added enhancement New feature or request 6.0.x v6.0.x labels Aug 28, 2026
@DamianSuess DamianSuess added this to the 6.0.x milestone Aug 28, 2026
@DamianSuess

Copy link
Copy Markdown
Contributor

Really wish GitHub would implement a "sync with target branch" button on the PR page
@Kinchul, would you mind syncing it up & the PR will be merged. Thank you

@DamianSuess DamianSuess linked an issue Aug 28, 2026 that may be closed by this pull request
@Kinchul
Kinchul force-pushed the vk/dispose-replayed-devices branch from 0b334d0 to d412a9e Compare August 31, 2026 07:03
@Kinchul

Kinchul commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Indeed it would be very convenient. All done, I rebased the branch on the latest develop. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.0.x v6.0.x enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddMatch eventually stacks up and breaks limit

2 participants