Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

old sources not released #1267

Closed
Closed

Description

@incanus

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.

Activity

  1. added
    performance
    on Apr 14, 2015
  2. added this to the iOS Beta 1 milestone on Apr 14, 2015
  3. incanus commented on Apr 14, 2015

    @incanus
    ContributorAuthor

    The style's destructor does get called, but Source's never does.

  4. changed the title [-]old sources, and possibly styles, not released[/-] [+]old sources not released[/+] on Apr 14, 2015
  5. ansis commented on Apr 15, 2015

    @ansis
    Contributor

    StyleBucket has a shared pointer to Source

    util::ptr<Source> source;

    StyleLayer has a shared pointer to StyleBucket
    util::ptr<const StyleBucket> bucket;

    Style has a shared pointer to StyleLayer
    std::vector<util::ptr<StyleLayer>> layers;

    VectorTileData has a shared pointer to Style
    util::ptr<Style> style;

    Source has pointers to VectorTileData
    std::map<TileID, std::weak_ptr<TileData>> tile_data;

    I'm still looking for a good way to fix this.

  6. jfirebaugh commented on Apr 15, 2015

    @jfirebaugh
    Contributor

    VectorTileData is supposed to break the reference chain when it starts the parse.

    Is it possible this happens only for cancelled tiles?

  7. incanus commented on Apr 15, 2015

    @incanus
    ContributorAuthor

    Looking at this.

  8. self-assigned this
    on Apr 15, 2015
  9. incanus commented on Apr 15, 2015

    @incanus
    ContributorAuthor

    StyleLayer, and thus StyleBucket, which holds a reference to Source, never go away.

  10. incanus commented on Apr 15, 2015

    @incanus
    ContributorAuthor

    Maybe unrelated, but any idea @kkaefer @jfirebaugh why we are not using smart pointers for StyleLayer like this?

    https://gist.github.com/incanus/af8a4cd9cb8ae46eec01

  11. jfirebaugh commented on Apr 15, 2015

    @jfirebaugh
    Contributor

    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.

  12. incanus commented on Apr 15, 2015

    @incanus
    ContributorAuthor

    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.

  13. incanus commented on Apr 16, 2015

    @incanus
    ContributorAuthor

    You were on the right track, @jfirebaugh — but so was I. Turns out VectorTileData may 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. 🔴 🐟 👎

    Fix incoming.

  14. incanus commented on Apr 16, 2015

    @incanus
    ContributorAuthor

    Yep, easily confirmed that cancelled vector tiles also don't get their style reset. Fixing.

  15. added 2 commits that reference this issue on Apr 16, 2015
    5dab378
    d29534e
  16. added a commit that references this issue on Apr 16, 2015
    c574acd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugperformance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions