Repository navigation
Fix native VehicleDecoder leak in DashKitDataSource - #249
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017nzxRV1bnDuyu5Ma2AgR7q
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DashKitDataSourcecreates a nativeVehicleDecoder(viaCanFrameDecoder) per connection but never frees it —CanFrameDecoder.destroy()has no callers. Every DashKit connect/reconnect fromConnectionViewModel(manual connect, foreground restore after a dead link) leaks a full decoder with its parsed DBC tables.CommaDataSourcealready frees its decoder indisconnect(); the DashKit path was missing it.Fix
DashKitDataSource.disconnect()callsdecoder.destroy()after removing the GATT listener.CanFrameDecoder.destroy()zeroes the handle;decodeFrame()returnsnullonce destroyed and the caller drops the packet. Both are@Synchronized, so a notification already in flight on the binder thread during teardown can't decode with a freed pointer.BLE-level auto-reconnects (e.g. DashKit reboot) are unaffected — the data source and decoder persist across those as before.
Testing
Samsung Galaxy S23 Ultra, Android 16.
dumpsys meminfotaken ~1 min apart across repeated DashKit connect/disconnect cycles:Host build of
VehicleDecoderwithconfig_dashkit.json: one decoder ≈ 7.2 MB native; 10 cycles leak 71.6 MB withoutdestroy(), 0.05 MB with it.🤖 Generated with Claude Code
meminfo-fixed-v0.9.1-after.txt
meminfo-fixed-v0.9.1-before.txt
meminfo-stock-v0.9.2-after.txt
meminfo-stock-v0.9.2-before.txt