Merge pull request #1024 from mapbox/mem_leaks

Fix a few memory leaks
This commit is contained in:
Thiago Marcos P. Santos
2015-03-20 15:42:35 +02:00
4 changed files with 96 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
#include <mbgl/mbgl.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/uv.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/platform/platform.hpp>
@@ -13,7 +14,7 @@
#include <sstream>
GLFWView *view = nullptr;
std::unique_ptr<GLFWView> view;
void quit_handler(int) {
if (view) {
@@ -62,7 +63,7 @@ int main(int argc, char *argv[]) {
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
view = new GLFWView();
view = mbgl::util::make_unique<GLFWView>();
mbgl::SQLiteCache cache("/tmp/mbgl-cache.db");
mbgl::DefaultFileSource fileSource(&cache);

View File

@@ -11,6 +11,7 @@ GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) {
}
GLFWView::~GLFWView() {
glfwDestroyWindow(window);
glfwTerminate();
}

91
scripts/valgrind.sup Normal file
View File

@@ -0,0 +1,91 @@
{
Valgrind gets confused with buffers managed by the graphics driver
Memcheck:Leak
...
obj:/usr/*/dri/r600_dri.so
...
}
{
GLFW _glfwCreateCursor()
Memcheck:Leak
match-leak-kinds: reachable
...
obj:/usr/*/libX11.so.6.3.0
...
fun:_glfwCreateCursor
...
}
{
GLFW _glfwPlatform*()
Memcheck:Leak
match-leak-kinds: reachable
...
fun:_glfwPlatform*
...
}
{
Buffer managed by OpenGL?
Memcheck:Cond
...
fun:_ZN4mbgl*Uniform*
...
fun:_ZN8GLFWView10invalidateEv
...
}
{
Buffer managed by OpenGL?
Memcheck:Cond
fun:_ZNSt7__equalILb0EE5equalIPKfS3_EEbT_S4_T0_
...
fun:_ZN4mbgl7Painter11renderLayerERKNS_10StyleLayerEPKNS_4Tile2IDEPKSt5arrayIfLm16EE
}
{
Valgrind doesn't like our make_unique (C++14 polyfill)
Memcheck:Leak
match-leak-kinds: reachable
fun:malloc
...
fun:_ZN4mbgl4util11make_unique*
...
}
{
dlopen doing its magic
Memcheck:Leak
match-leak-kinds: reachable
...
fun:_dl_open
...
}
{
X11 false positive
Memcheck:Leak
match-leak-kinds: reachable
...
obj:/usr/*/libX11.so.6.3.0
...
fun:_XrmInitParseInfo
...
}
{
OpenSSL false positive
Memcheck:Leak
...
fun:CRYPTO_malloc
...
}
{
OpenSSL false positive
Memcheck:Leak
...
fun:CRYPTO_realloc
...
}
{
Libcurl false positive
Memcheck:Leak
fun:malloc
...
obj:/usr/*/libcurl.so.4.3.0
fun:curl_multi_socket_action
...
}

View File

@@ -19,6 +19,7 @@ LineAtlas::~LineAtlas() {
std::lock_guard<std::recursive_mutex> lock(mtx);
MBGL_CHECK_ERROR(glDeleteTextures(1, &texture));
delete[] data;
texture = 0;
}