question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenLayers arrays are using way too much memory in map with vector tiles

See original GitHub issue

Describe the bug

Even with a very low cacheSize (configured to 2, which I think isn’t even recommended), after navigating a bit on a map rendered by OpenLayers (with MVT vector tiles data) the page starts using way too much memory (like > 200MB), which slows down the experience dramatically on smartphones that doesn’t have more than 1GB of RAM.

To Reproduce Steps to reproduce the behavior:

  1. Open a map with vector tiles (example);
  2. Navigate a bit on the map, zooming down and up, going to different places of the map;
  3. See memory usage increase dramatically on Chrome DevTools;

Expected behavior The memory usage should stay more or less the same (< 100 MB), probably by discarding old data automatically.

High memory usage on map with vector tiles

Additional information

Curiously, most of the memory is used specifically on…arrays (see image below), and that happens only on maps with vector tiles.

Statistics of memory usage

Also, this happens both on OpenLayers 5 and on OpenLayers 6, which means the problem isn’t solved and it isn’t specific to cacheSize (even throught cacheSize seems to help a bit to reduce the memory usage). Curiously, this library seems to be more optimized than Leaflet.VectorGrid, but this specific problem is bothering me a bit.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ahocevarcommented, Sep 4, 2019

@pecet86 You can fork this repository (by clicking the “Fork” button at the top of https://github.com/openlayers/openlayers, and then create a branch in your fork to create a pull request from.

0reactions
fjorgemotacommented, Nov 6, 2019

Now that v6 is released and doesn’t have this problem, I’ll close the issue.

Thanks for fixing this issue. =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

performance issue when adding vector layers to openLayers ...
performance issue when adding vector layers to openLayers map where it's consuming too much memory/GPU usage when upgrading to v.6 and v.7.
Read more >
OpenLayers 5 Vector Tiles Styling and ESPG:4326 projection ...
Turns out the issue was the resolutions were not being mapped to the proper zoom levels. The fix was as easy as passing...
Read more >
The VectorTile layer · HonKit - OpenLayers
OpenLayers supports vector tiles through the VectorTile layer. A world map rendered from vector data. We'll start with the same markup in index.html...
Read more >
Performance Testing on Vector vs. Raster Map Tiles ... - MDPI
This article describes an experiment to test both raster and vector tile methods. ... while the use of vector tiles is becoming more...
Read more >
Rendering big geodata on the fly with GeoJSON-VT | by Mapbox
The best way to optimize the data for all zoom levels and screens is to cut it into vector tiles. Traditionally, this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found