You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
If you change map styles, the new one loads async, parses, and creates its source(s). However, the old sources~~, and possibly the style,~~ never go away.
This was revealed in #1255 (comment) when it was found that naturally, the source's cache also doesn't go away, so we start accumulating sources with ever-growing tile caches.
Smart pointers should only be used when it is necessary to express ownership or lifetime semantics. render, hasData, renderLayer, etc. do not need to express such semantics -- they receive a layer reference, do something with it, and then return, without storing a reference to the layer. So there's no need to use a smart pointer.
Welp, definitely tracked it down to my block that creates the annotation layer. Can't figure out why yet, but commenting that out gets layers, buckets, and sources to release properly.
You were on the right track, @jfirebaugh — but so was I. Turns out VectorTileDatamay be holding onto the style for cancelled tiles (still gonna dig on that, plus found a bug related to annotations at z0 that I'll also hit), but LiveTileData was always holding onto the style in cases of no annotations, because LiveTile objects were never coming out of annotationManager.getTile(), thus parse() was never called, nor style.reset(). Since LiveTileData are always created with a style reference, we'll have to always style.reset().
Digging around in the creation of the annotations style layer and its memory management for the sources, sourcesMap, layers, and layersMap was a red herring. 🔴 🐟 👎
Activity
incanus commentedon Apr 14, 2015
The style's destructor does get called, but
Source's never does.[-]old sources, and possibly styles, not released[/-][+]old sources not released[/+]ansis commentedon Apr 15, 2015
StyleBucket has a shared pointer to Source
mapbox-gl-native/src/mbgl/style/style_bucket.hpp
Line 23 in 88b8d45
StyleLayer has a shared pointer to StyleBucket
mapbox-gl-native/src/mbgl/style/style_layer.hpp
Line 70 in 88b8d45
Style has a shared pointer to StyleLayer
mapbox-gl-native/src/mbgl/style/style.hpp
Line 37 in 88b8d45
VectorTileData has a shared pointer to Style
mapbox-gl-native/src/mbgl/map/vector_tile_data.hpp
Line 63 in 88b8d45
Source has pointers to VectorTileData
mapbox-gl-native/src/mbgl/map/source.hpp
Line 98 in 88b8d45
I'm still looking for a good way to fix this.
jfirebaugh commentedon Apr 15, 2015
VectorTileData is supposed to break the reference chain when it starts the parse.
Is it possible this happens only for cancelled tiles?
incanus commentedon Apr 15, 2015
Looking at this.
incanus commentedon Apr 15, 2015
StyleLayer, and thusStyleBucket, which holds a reference toSource, never go away.incanus commentedon Apr 15, 2015
Maybe unrelated, but any idea @kkaefer @jfirebaugh why we are not using smart pointers for
StyleLayerlike this?https://gist.github.com/incanus/af8a4cd9cb8ae46eec01
jfirebaugh commentedon Apr 15, 2015
Smart pointers should only be used when it is necessary to express ownership or lifetime semantics.
render,hasData,renderLayer, etc. do not need to express such semantics -- they receive a layer reference, do something with it, and then return, without storing a reference to the layer. So there's no need to use a smart pointer.incanus commentedon Apr 15, 2015
Cool, thanks for the info @jfirebaugh.
Welp, definitely tracked it down to my block that creates the annotation layer. Can't figure out why yet, but commenting that out gets layers, buckets, and sources to release properly.
incanus commentedon Apr 16, 2015
You were on the right track, @jfirebaugh — but so was I. Turns out
VectorTileDatamay be holding onto the style for cancelled tiles (still gonna dig on that, plus found a bug related to annotations atz0that I'll also hit), butLiveTileDatawas always holding onto the style in cases of no annotations, becauseLiveTileobjects were never coming out ofannotationManager.getTile(), thusparse()was never called, norstyle.reset(). SinceLiveTileDataare always created with a style reference, we'll have to alwaysstyle.reset().Digging around in the creation of the annotations style layer and its memory management for the
sources,sourcesMap,layers, andlayersMapwas a red herring. 🔴 🐟 👎Fix incoming.
incanus commentedon Apr 16, 2015
Yep, easily confirmed that cancelled vector tiles also don't get their style reset. Fixing.
fixes #1267: properly break reference cycle with tile data & style
fixes #1267: properly break reference cycle with live tile data & style
Merge pull request #1280 from mapbox/source-release-fix