Skip to content

Stop keeping every generation of a module alive in the daemon - #1024

Open
hxreborn wants to merge 1 commit into
JingMatrix:masterfrom
hxreborn:fix/module-app-service-leak
Open

hxreborn wants to merge 1 commit into
JingMatrix:masterfrom
hxreborn:fix/module-app-service-leak

Conversation

@hxreborn

Copy link
Copy Markdown

Hi! ModuleAppService.serviceMap is a WeakHashMap<LoadedModule, ModuleAppService>, but each ModuleAppService holds its LoadedModule, so the weak key never clears. vectord keeps every generation of a module that reached getOrPut, along with one SharedMemory per dex in code.preLoadedDexes

This keys the map by package name, replaces the entry when a new LoadedModule arrives, and drops every entry whose module was removed or replaced when ConfigCache publishes a new module set

Tested on Android 16 with a module whose debug build has 16 dex files, its app opened after each install and a GC forced before each read of vectord's ashmem fd count:

             master ddeed8ca   this PR af11dee3
start               41                41
install 1           41                41
install 2           57                41
install 3           73                41
install 4           89                41
install 5          105                41

On this PR installs 1 to 4 were each a successful auto hot reload in the same app process, and the module app bound its service after every install

Fork CI run with the debug and release zips: https://github.com/hxreborn/Vector/actions/runs/39419055272

Fixes #1023

Signed-off-by: hxreborn <hxreborn@duck.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vectord keeps every installed generation of a module in memory until reboot

1 participant