Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actors don't properly clean up callback references #5443

Closed
tgecho opened this issue Oct 10, 2017 · 2 comments
Closed

Actors don't properly clean up callback references #5443

tgecho opened this issue Oct 10, 2017 · 2 comments
Labels

Comments

@tgecho
Copy link

tgecho commented Oct 10, 2017

mapbox-gl-js version: 0.40.1

Steps to Trigger Behavior

  1. Load any map (for example: https://www.mapbox.com/mapbox-gl-js/examples/)
  2. Count the number of callbacks retained by the worker actors:
    On the example page, run this in the console: document.getElementById('demo').contentWindow.map.style.dispatcher.actors.reduce((total, actor) => Object.keys(actor.callbacks).length + total, 0)

Expected Behavior

The number of callbacks should rise and fall back to 0

Actual Behavior

The number of callbacks continues to climb as you interact with the map

Background / Details

I'm investigating some an apparent memory leaks (in a much more complicated scenario with auto refreshing data), and I noticed references were being held open by this issue. Basically, the actor saves a callback, but in some cases the worker never calls back since many if its methods don't use the done param. The primary culprits seem to be setLayers and updateLayers in source/worker.js, though I noticed others.

Experimentally clearing them with map.style.dispatcher.actors.forEach(a => a.callbacks = {}) seems to somewhat bring memory usage back down, though not completely.

@jfirebaugh
Copy link
Contributor

Good catch!

@tgecho
Copy link
Author

tgecho commented Oct 11, 2017

I'm trying my hand at a fix for this and I've noticed that loadTile is another leaky event type. It has a callback, so retaining it is correct, but apparently it doesn't always get called back, especially when zooming/panning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants