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

Raster/TexturePoolHolder leaks textures #5136

Closed
jonkan opened this issue May 25, 2016 · 16 comments · Fixed by #5141
Closed

Raster/TexturePoolHolder leaks textures #5136

jonkan opened this issue May 25, 2016 · 16 comments · Fixed by #5141
Labels
bug Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage

Comments

@jonkan
Copy link

jonkan commented May 25, 2016

We're seeing a lot of "out of memory"-crashes after a while of heavy panning (iPad Air 2, a raster only stylesheet containing two raster-layers, both using 1024px tiles).

Trying to track down what's eating all the memory I found that in gl_object_store.cpp, TexturePoolHolder::reset() it seems textures are never deleted due to the line if (!bool()) return;.
There's also the line if (bool()) return; which to me seems to have no purpose?
Or am I missing something?

I can also add that, with those lines removed TexturePoolHolder::reset() seems to always be called having a NULL objectStore when called from Raster::~Raster()...

@jfirebaugh
Copy link
Contributor

if (bool()) originates in 1241730 -- cc @brunoabinader.

@1ec5 1ec5 added the performance Speed, stability, CPU usage, memory usage, or power usage label May 25, 2016
@jonkan
Copy link
Author

jonkan commented May 25, 2016

Tested with latest master now and the crashes are easily reproducible with the "iosapp"-target and the default "Satellite"-style by constantly panning in one direction, takes a while though..

screen shot 2016-05-25 at 20 04 03

@brunoabinader
Copy link
Member

There's also the line if (bool()) return; which to me seems to have no purpose? Or am I missing something?

Oh my, this looks like my eyes missed this while batch replacing strings on my IDE. Will send a patch soon.

@brunoabinader brunoabinader added the Core The cross-platform C++ core, aka mbgl label May 25, 2016
@brunoabinader
Copy link
Member

Checking the code, the bool() is not a typo - it is using the bool() from https://github.com/mapbox/mapbox-gl-native/blob/master/src/mbgl/gl/gl_object_store.hpp#L114.

@jonkan
Copy link
Author

jonkan commented May 25, 2016

Oh, that I'd missed.. I tested again with a clean master (as I had commented out just that line last time) and the memory-leak/crashing is still there.

@brunoabinader
Copy link
Member

@jonkan can you please verify the patches from #5141?

@jonkan
Copy link
Author

jonkan commented May 26, 2016

@jonkan can you please verify the patches from #5141?

👍 For the purpose of readability if (!created()) return; is more clear to me than if (!bool()) return;, not sure I understand if the PR was intended to fix more than just the readability aspect. The memory-leaking/crashing is still present, but might have its cause somewhere else..

brunoabinader added a commit that referenced this issue May 26, 2016
Fixes an issue where a moved {GL,TexturePool}Holder would use an invalid
pointer when accessing 'objectStore'.

Fixes #5136.
@brunoabinader
Copy link
Member

Reopening for verification - @jonkan can you please verify?

@brunoabinader brunoabinader reopened this May 26, 2016
@friedbunny
Copy link
Contributor

We will want to include an iOS changelog entry for this fix, as it affected iOS 3.2.x.

Android 4.0.x is also affected, but I’m not sure if 4.1.0 will include this? /cc @bleege

@bleege
Copy link
Contributor

bleege commented May 26, 2016

@friedbunny Thanks for the ping. I branched 4.1.0-beta.1 off of 26a425f before the final two commits ( b2b2797 and c111250 ) had been pushed to master. We'll have to cherry pick them to the release-android-v4.1.0 branch when it's been verified and @brunoabinader closes this issue.

/cc @tobrun @cammace

@jonkan
Copy link
Author

jonkan commented May 26, 2016

@brunoabinader Awesome! That solved it, not seeing any crashes or leaks. 👍

@brunoabinader
Copy link
Member

Thank you @jonkan!

@bleege
Copy link
Contributor

bleege commented May 27, 2016

Thanks for confirming and getting this fixed @jonkan @brunoabinader. I'll cherry pick the remaining two commits into the release-android-v4.1.0 branch now so that they'll ship with future 4.1.0 builds and releases.

@brunoabinader
Copy link
Member

Awesome @bleege, thanks!

bleege pushed a commit that referenced this issue May 27, 2016
Fixes an issue where a moved {GL,TexturePool}Holder would use an invalid
pointer when accessing 'objectStore'.

Fixes #5136.
@bleege
Copy link
Contributor

bleege commented May 27, 2016

Cherries have been picked!

screen shot 2016-05-27 at 10 43 22 am

@bleege bleege added this to the android-v4.1.0 milestone May 27, 2016
@friedbunny
Copy link
Contributor

Updated the iOS changelog in 2f25c1a — this issue will be fixed in the v3.3.0 release (and whichever pre-release comes after alpha 3).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Core The cross-platform C++ core, aka mbgl performance Speed, stability, CPU usage, memory usage, or power usage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants