Skip to content

[PERF] mail: fix memory leak from running mail tests#5165

Merged
jeanschoenlaub merged 1 commit into
master-owl3-migrationfrom
master-owl3-migration-memleak-aku
May 15, 2026
Merged

[PERF] mail: fix memory leak from running mail tests#5165
jeanschoenlaub merged 1 commit into
master-owl3-migrationfrom
master-owl3-migration-memleak-aku

Conversation

@alexkuhn
Copy link
Copy Markdown

@alexkuhn alexkuhn commented May 14, 2026

Before this commit, running the whole @mail HOOT tests suite leads to heavy memory leak.

This happens for one main reason: internal effects in @mail are not properly disposed in-between tests. This includes onChange utility function, which internally uses immediateEffect.

  1. onChange was returning a proxy, but this return value was never used. This commit now makes it return a function to dispose effects that are internally used. Some components that were using onChange now can properly dispose these effects on destroy

  2. onChange and Record.onChange (= a version of onChange that follows the store's update cycle) made in store, services, and JS models had no dispose strategy. This commit now adds several functions for register(Record)OnChange and runDisposeFn(s), so that all these dispose functions are executed in-between each test.

Browser tab RAM of running whole @mail test:

  • before this commit: 2GB
  • after this commit: 250MB

@robodoo
Copy link
Copy Markdown

robodoo commented May 14, 2026

This PR targets the un-managed branch odoo-dev/odoo:master-owl3-migration, it needs to be retargeted before it can be merged.

@alexkuhn alexkuhn force-pushed the master-owl3-migration-memleak-aku branch from f3557d4 to 2e6ee4b Compare May 14, 2026 21:29
@alexkuhn
Copy link
Copy Markdown
Author

For comparison, same suite in master of @mail is around 500MB, so this makes it even better!

Before this commit, running the whole `@mail` HOOT tests suite leads
to heavy memory leak.

This happens for one main reason: internal effects in `@mail` are not
properly disposed in-between tests. This includes `onChange` utility
function, which internally uses `immediateEffect`.

1. `onChange` was returning a proxy, but this return value was never
used. This commit now makes it return a function to dispose effects
that are internally used. Some components that were using `onChange`
now can properly dispose these effects on destroy

2. `onChange` and `Record.onChange` (= a version of `onChange` that
follows the store's update cycle) made in store, services, and JS
models had no dispose strategy. This commit now adds several
functions for `register(Record)OnChange` and `runDisposeFn(s)`, so
that all these dispose functions are executed in-between each test.

Browser tab RAM of running whole `@mail test`:
- before this commit: 2GB
- after this commit: 250MB
@alexkuhn alexkuhn force-pushed the master-owl3-migration-memleak-aku branch from 2e6ee4b to c566884 Compare May 14, 2026 21:43
@jeanschoenlaub jeanschoenlaub merged commit 8b3d41d into master-owl3-migration May 15, 2026
@jeanschoenlaub jeanschoenlaub deleted the master-owl3-migration-memleak-aku branch May 15, 2026 11:44
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.

3 participants