#17497·openlayers

Memory leak in MouseWheelZoom interaction

Author: lysekCreated May 28, 2026Updated Sep 18, 2026
Labelspull request acceptedbug

Describe the bug In the MouseWheelZoom interaction, there are events registered in the setMap method for Ctrl key which reference the main document. When the interaction is removed or whole map is disposed, those handlers are never removed and garabage collection does not discard them (I mean the last registration that is never removed by calling the setMap again).

https://github.com/openlayers/openlayers/blob/main/src/ol/interaction/MouseWheelZoom.js

To Reproduce

  • Create a map with MouseWheelZoom interaction
  • Unload the map
  • Analyze memory allocation

Issue can be reviewed here https://jsfiddle.net/v1c2564x/

  • use Chrome/Chromium
  • F12 -> memory tab
  • start "Allocation on timeline" for fiddle (not main)
  • click make Maps button couple of times (at least 10x)
  • perform garbage collection
  • stop the recording
  • find the Ma variable (in minified code that is the MouseWheelZoom class)
  • observe that these allocation keeps growing when the map is being recreated

Expected behavior Ctrl handlers should be removed when interaction/map is disposed.