opengl Mesh类中的内存泄漏

时间:2015-07-29 08:23:43

标签: c++ opengl memory-leaks

我最近用 valgrind 检查了我的opengl引擎的内存泄漏,发现我在我的opengl网格类中泄漏了一些东西(~7000):问题是问题;任何人都可以指出我泄漏资源的地方吗?

这是mesh.h:

#pragma once
#include <GL/glew.h>
#include <glm/glm.hpp>
#include "alpha/Vertex.h"
#include "alpha/ModelLoader.h"
#include <vector>
#include <memory>

void glDrawMode(GLenum drawMode);

struct IndexedModel{
    std::vector<glm::vec3> positions;
    std::vector<glm::vec2> texCoords;
    std::vector<glm::vec3> normals;
    std::vector<glm::vec3> tangents;
    std::vector<unsigned int> indices;
};

namespace glDetail
{

    class CMesh
    {
    public:
        CMesh(Vertex* vertices, unsigned int numVertices, unsigned int* indeces, unsigned int numIndices);
        CMesh(const char* fileName);
        virtual ~CMesh();
        void Draw() const;
        void Dispose();
        bool HasDisposed();

        ///assignement operators are deleted methods : the user should use the move constructor instead.
        CMesh(CMesh&& other);
        CMesh(const CMesh& other) = delete;
        CMesh& operator=(const CMesh& other) = delete;
    private:
        enum{
            POSITION_VB,
            TEXCOORD_VB,
            NORMAL_VB,
            TANGENT_VB,
            INDEX_VB,
            NUM_BUFFERS = 5
        };
        void initMesh(const IndexedModel& model);
        GLuint m_vertexArrayObject = 0;
        GLuint m_vertexArrayBuffers[NUM_BUFFERS];
        unsigned int m_drawCount;
        bool m_hasDisposed = false;
    };
}

typedef std::shared_ptr<glDetail::CMesh> Mesh;

Mesh CreateMesh(Vertex* vertices, unsigned int numVertices,
                unsigned int* indeces, unsigned int numIndices);
Mesh CreateMesh(const char* fileName);

和mesh.cpp:

#include "alpha/Mesh.h"
#include "alpha/LogManager.h"
#include <vector>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <glm/glm.hpp>

static GLenum DRAW_MODE = GL_TRIANGLES;

void glDrawMode(GLenum drawMode){
    DRAW_MODE = drawMode;
}

Mesh CreateMesh(
                    Vertex* vertices, unsigned int numVertices,
                    unsigned int* indeces, unsigned int numIndices
                )
{
    return std::make_shared<glDetail::CMesh>(vertices, numVertices, indeces, numIndices);
}
Mesh CreateMesh(const char* fileName){
    return std::make_shared<glDetail::CMesh>(fileName);
}

namespace glDetail
{

    CMesh::CMesh(Vertex* vertices, unsigned int numVertices, unsigned int* indeces, unsigned int numIndeces){
        IndexedModel model;

        for (unsigned int i = 0; i < numVertices; i++){
            model.positions.push_back(*vertices[i].getPos());
            model.texCoords.push_back(*vertices[i].getTexCoord());
            model.normals.push_back(*vertices[i].getNormal());
        }
        for (unsigned int i = 0; i < numIndeces; i++)
            model.indices.push_back(indeces[i]);
        initMesh(model);
    }

    CMesh::CMesh(const char* fileName){
        Assimp::Importer importer;

        const aiScene* scene = importer.ReadFile(fileName,  aiProcess_Triangulate |
                                                            aiProcess_GenSmoothNormals |
                                                            aiProcess_FlipUVs |
                                                            aiProcess_CalcTangentSpace
                                                            );
        if(!scene){
            LOG_ERROR("Mesh", "ERROR LOADING MESH ! : CHECK THE SUPPORTED MODEL TYPES MODEL I OR THE FILE PATH !");
            abort();
        }
        const aiMesh* model = scene->mMeshes[0];

        std::vector<Vertex> vertices;
        std::vector<unsigned int> indices;

        const aiVector3D aiZeroVector(.0f, .0f, .0f);
        IndexedModel out;

        for(unsigned i = 0; i < model->mNumVertices; ++i)
        {
            const aiVector3D* pPos = &(model->mVertices[i]);
            const aiVector3D* pNormal = &(model->mNormals[i]);
            const aiVector3D* pTexCoord = model->HasTextureCoords(0) ? &(model->mTextureCoords[0][i]) : &aiZeroVector;

            const aiVector3D* pTangent = &(model->mTangents[i]);

            Vertex vert (
                            glm::vec3(pPos->x, pPos->y, pPos->z),///positions
                            glm::vec2(pTexCoord->x, pTexCoord->y),///UV coords
                            glm::vec3(pNormal->x, pNormal->y, pNormal->z),///normals
                            glm::vec3(pTangent->x, pTangent->y, pTangent->z)///tangents

                        );

            vertices.push_back(vert);

            out.positions.push_back(*vert.getPos());
            out.texCoords.push_back(*vert.getTexCoord());
            out.normals.push_back(*vert.getNormal());
            out.tangents.push_back(*vert.getTangent());
        }
        for(unsigned i = 0; i < model->mNumFaces; ++i){
            const aiFace& face = model->mFaces[i];
            assert(face.mNumIndices == 3);
            indices.push_back(face.mIndices[0]);
            indices.push_back(face.mIndices[1]);
            indices.push_back(face.mIndices[2]);
        }


        importer.FreeScene();

        out.indices = indices;
        initMesh(out);
    }

    CMesh::CMesh(CMesh&& other){
        this->m_vertexArrayObject = other.m_vertexArrayObject;
        other.m_vertexArrayObject = 0;
        for(unsigned i = 0; i < NUM_BUFFERS; ++i){
            this->m_vertexArrayBuffers[i] = other.m_vertexArrayBuffers[i];
            other.m_vertexArrayBuffers[i] = 0;
        }
        this->m_drawCount = other.m_drawCount;
        this->m_hasDisposed = other.m_hasDisposed;
        other.m_hasDisposed = true;
    }

    void CMesh::initMesh(const IndexedModel& model){
        m_drawCount = model.indices.size();

        glGenVertexArrays(1, &m_vertexArrayObject);
        glBindVertexArray(m_vertexArrayObject);

        glGenBuffers(NUM_BUFFERS, m_vertexArrayBuffers);

        std::cout << "Mesh : Generated VAO ; ID = " << m_vertexArrayObject << "\n";
        std::cout << "Mesh : Generated Vertex Buffers ; Number of buffers = "
        << NUM_BUFFERS << "\n";

        for(unsigned i = 0; i < NUM_BUFFERS; ++i){
            std::cout << "\t Buffer " << i << "; ID = " << m_vertexArrayBuffers[i] << "\n";
        }

        glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[POSITION_VB]);
        glBufferData(GL_ARRAY_BUFFER, model.positions.size() * sizeof(model.positions[0]), &model.positions[0], GL_STATIC_DRAW);
        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

        glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[TEXCOORD_VB]);
        glBufferData(GL_ARRAY_BUFFER, model.positions.size() * sizeof(model.texCoords[0]), &model.texCoords[0], GL_STATIC_DRAW);
        glEnableVertexAttribArray(1);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);

        glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[NORMAL_VB]);
        glBufferData(GL_ARRAY_BUFFER, model.normals.size() * sizeof(model.normals[0]), &model.normals[0], GL_STATIC_DRAW);
        glEnableVertexAttribArray(2);
        glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

        glBindBuffer(GL_ARRAY_BUFFER, m_vertexArrayBuffers[TANGENT_VB]);
        glBufferData(GL_ARRAY_BUFFER, model.tangents.size() * sizeof(model.tangents[0]), &model.tangents[0], GL_STATIC_DRAW);
        glEnableVertexAttribArray(3);
        glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vertexArrayBuffers[INDEX_VB]);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, model.indices.size() * sizeof(model.indices[0]), &model.indices[0], GL_STATIC_DRAW);

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2);
        glDisableVertexAttribArray(3);

        glBindVertexArray(0);
    }

    CMesh::~CMesh(){
       this->Dispose();
    }

    void CMesh::Draw() const{
        glBindVertexArray(m_vertexArrayObject);

        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        glEnableVertexAttribArray(2);
    /**/glEnableVertexAttribArray(3);

        glDrawElements(DRAW_MODE, m_drawCount, GL_UNSIGNED_INT, 0);

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2);
    /**/glDisableVertexAttribArray(3);


        glBindVertexArray(0);
    }

    bool CMesh::HasDisposed(){
        return m_hasDisposed;
    }

    void CMesh::Dispose(){
        if(!m_hasDisposed){
            glDeleteBuffers(NUM_BUFFERS, m_vertexArrayBuffers);
            glDeleteVertexArrays(1, &m_vertexArrayObject);
            LOG("Mesh", "Deleted GL buffers !");
            m_hasDisposed = true;
        }
    }
}

另外,这是valgring日志:

==3284== Memcheck, a memory error detector
==3284== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3284== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==3284== Command: ./Alpha++ clear
==3284== 
==3284== Syscall param writev(vector[...]) points to uninitialised byte(s)
==3284==    at 0x6A0A16D: ??? (syscall-template.S:81)
==3284==    by 0x86B1DFD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3284==    by 0x86B2190: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3284==    by 0x86B2210: xcb_writev (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3284==    by 0x798311D: _XSend (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x79835FD: _XReply (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x796ED9E: XInternAtom (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x5419F6A: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x541ADB6: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540E14B: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540DF4F: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x5378506: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==  Address 0xdb286f3 is 35 bytes inside a block of size 16,384 alloc'd
==3284==    at 0x4C2DC90: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x7973BF1: XOpenDisplay (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x5418D44: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540DF10: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x5378506: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x4063D6: SDL_Handle::SDL_Handle() (SDL_Handle.cpp:9)
==3284==    by 0x42DAE9: Window::Window(unsigned int, unsigned int, unsigned int, unsigned int, char const*, bool, bool) (Window.cpp:10)
==3284==    by 0x42E8CD: main (main.cpp:8)
==3284== 
SDL_Handle : Initialized SDl Successfully !
Opengl version : 3.3 (Core Profile) Mesa 10.5.2
Opengl vendor : Intel Open Source Technology Center
GLEW version : 1.10.0
Intialized Texture : ID = 1
==3284== Invalid read of size 4
==3284==    at 0x42A51E: glDetail::CTexture::Dispose() (Texture.cpp:69)
==3284==    by 0x42A414: glDetail::CTexture::~CTexture() (Texture.cpp:58)
==3284==    by 0x42A453: glDetail::CTexture::~CTexture() (Texture.cpp:59)
==3284==    by 0x42E937: main (main.cpp:12)
==3284==  Address 0x114aba60 is 16 bytes inside a block of size 24 free'd
==3284==    at 0x4C2D2E0: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x42A0B3: glDetail::TextureData::~TextureData() (Texture.cpp:28)
==3284==    by 0x42A515: glDetail::CTexture::Dispose() (Texture.cpp:68)
==3284==    by 0x42A414: glDetail::CTexture::~CTexture() (Texture.cpp:58)
==3284==    by 0x42A453: glDetail::CTexture::~CTexture() (Texture.cpp:59)
==3284==    by 0x42E937: main (main.cpp:12)
==3284== 
Texture object disposed; ID was 1 !
Mesh : Generated VAO ; ID = 1
Mesh : Generated Vertex Buffers ; Number of buffers = 5
     Buffer 0; ID = 1
     Buffer 1; ID = 2
     Buffer 2; ID = 3
     Buffer 3; ID = 4
     Buffer 4; ID = 5
Shader created : ID = 3
Intialized Texture : ID = 2
Intialized Texture : ID = 3
FPS : 27
FPS : 60
FPS : 49
FPS : 57
FPS : 62
FPS : 51
FPS : 59
FPS : 61
FPS : 58
FPS : 61
FPS : 55
FPS : 62
FPS : 56
==3284== Invalid read of size 4
==3284==    at 0x42A51E: glDetail::CTexture::Dispose() (Texture.cpp:69)
==3284==    by 0x42A414: glDetail::CTexture::~CTexture() (Texture.cpp:58)
==3284==    by 0x42D974: void __gnu_cxx::new_allocator<glDetail::CTexture>::destroy<glDetail::CTexture>(glDetail::CTexture*) (new_allocator.h:124)
==3284==    by 0x42D92A: std::enable_if<std::__and_<std::allocator_traits<std::allocator<glDetail::CTexture> >::__destroy_helper<glDetail::CTexture>::type>::value, void>::type std::allocator_traits<std::allocator<glDetail::CTexture> >::_S_destroy<glDetail::CTexture>(std::allocator<glDetail::CTexture>&, glDetail::CTexture*) (alloc_traits.h:282)
==3284==    by 0x42D8D2: void std::allocator_traits<std::allocator<glDetail::CTexture> >::destroy<glDetail::CTexture>(std::allocator<glDetail::CTexture>&, glDetail::CTexture*) (alloc_traits.h:411)
==3284==    by 0x42D7CA: std::_Sp_counted_ptr_inplace<glDetail::CTexture, std::allocator<glDetail::CTexture>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:524)
==3284==    by 0x430CFD: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==3284==    by 0x4309C0: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:666)
==3284==    by 0x4304E5: std::__shared_ptr<glDetail::CTexture, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:914)
==3284==    by 0x4304FF: std::shared_ptr<glDetail::CTexture>::~shared_ptr() (shared_ptr.h:93)
==3284==    by 0x430785: Material::~Material() (Light.h:57)
==3284==    by 0x42EEAE: main (main.cpp:26)
==3284==  Address 0xddff7d0 is 16 bytes inside a block of size 24 free'd
==3284==    at 0x4C2D2E0: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x42A0B3: glDetail::TextureData::~TextureData() (Texture.cpp:28)
==3284==    by 0x42A515: glDetail::CTexture::Dispose() (Texture.cpp:68)
==3284==    by 0x42A414: glDetail::CTexture::~CTexture() (Texture.cpp:58)
==3284==    by 0x42D974: void __gnu_cxx::new_allocator<glDetail::CTexture>::destroy<glDetail::CTexture>(glDetail::CTexture*) (new_allocator.h:124)
==3284==    by 0x42D92A: std::enable_if<std::__and_<std::allocator_traits<std::allocator<glDetail::CTexture> >::__destroy_helper<glDetail::CTexture>::type>::value, void>::type std::allocator_traits<std::allocator<glDetail::CTexture> >::_S_destroy<glDetail::CTexture>(std::allocator<glDetail::CTexture>&, glDetail::CTexture*) (alloc_traits.h:282)
==3284==    by 0x42D8D2: void std::allocator_traits<std::allocator<glDetail::CTexture> >::destroy<glDetail::CTexture>(std::allocator<glDetail::CTexture>&, glDetail::CTexture*) (alloc_traits.h:411)
==3284==    by 0x42D7CA: std::_Sp_counted_ptr_inplace<glDetail::CTexture, std::allocator<glDetail::CTexture>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:524)
==3284==    by 0x430CFD: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==3284==    by 0x4309C0: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:666)
==3284==    by 0x4304E5: std::__shared_ptr<glDetail::CTexture, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:914)
==3284==    by 0x4304FF: std::shared_ptr<glDetail::CTexture>::~shared_ptr() (shared_ptr.h:93)
==3284== 
Texture object disposed; ID was 2 !
Texture object disposed; ID was 3 !
Disposed Shader object : ID was 3
Mesh : Deleted GL buffers !
SDL_Handle : Has Quit SDl Successfully !
==3284== 
==3284== HEAP SUMMARY:
==3284==     in use at exit: 88,093 bytes in 771 blocks
==3284==   total heap usage: 180,912 allocs, 180,141 frees, 276,082,133 bytes allocated
==3284== 
==3284== 16 bytes in 2 blocks are definitely lost in loss record 51 of 397
==3284==    at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x6998429: strdup (strdup.c:42)
==3284==    by 0x79AD7F6: ??? (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x79AE5D4: _XimSetICValueData (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x79A9C75: _XimLocalCreateIC (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x798FDF4: XCreateIC (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x541ABB0: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x541AFC5: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540E14B: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540DF4F: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x5378506: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x4063D6: SDL_Handle::SDL_Handle() (SDL_Handle.cpp:9)
==3284== 
==3284== 16 bytes in 2 blocks are definitely lost in loss record 52 of 397
==3284==    at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x6998429: strdup (strdup.c:42)
==3284==    by 0x79AD7F6: ??? (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x79AE5D4: _XimSetICValueData (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x79A9C75: _XimLocalCreateIC (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x798FDF4: XCreateIC (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x541ABB0: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x541AFC5: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540E14B: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x42DC35: Window::Window(unsigned int, unsigned int, unsigned int, unsigned int, char const*, bool, bool) (Window.cpp:29)
==3284==    by 0x42E8CD: main (main.cpp:8)
==3284== 
==3284== 198 bytes in 6 blocks are definitely lost in loss record 360 of 397
==3284==    at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x796A620: XGetWindowProperty (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==3284==    by 0x5412E81: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x541364F: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x53A74D6: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x53A7533: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x40D29B: InputHandler::Update() (InputHandler.cpp:11)
==3284==    by 0x42E5B5: main::{lambda(float)#1}::operator()(float) const (main.cpp:34)
==3284==    by 0x42F1BF: std::_Function_handler<void (float), main::{lambda(float)#1}>::_M_invoke(std::_Any_data const&, float) (functional:2039)
==3284==    by 0x430A1F: std::function<void (float)>::operator()(float) const (functional:2439)
==3284==    by 0x42E42E: util::InMainLoop(unsigned int, bool&, std::function<void (float)>, std::function<void ()>, bool) (Util.h:28)
==3284==    by 0x42EE7C: main (main.cpp:58)
==3284== 
==3284== 352 bytes in 1 blocks are definitely lost in loss record 367 of 397
==3284==    at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x4E53C45: glXGetFBConfigs (in /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0)
==3284==    by 0x4E54A05: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0)
==3284==    by 0x541867C: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x540D1DF: ??? (in /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0)
==3284==    by 0x42DCC1: Window::Window(unsigned int, unsigned int, unsigned int, unsigned int, char const*, bool, bool) (Window.cpp:37)
==3284==    by 0x42E8CD: main (main.cpp:8)
==3284== 
==3284== 7,280 bytes in 1 blocks are definitely lost in loss record 395 of 397
==3284==    at 0x4C2C100: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3284==    by 0x598647E: ??? (in /usr/lib/libassimp.so.3.0.1264)
==3284==    by 0x597F37D: ??? (in /usr/lib/libassimp.so.3.0.1264)
==3284==    by 0x58139E5: ??? (in /usr/lib/libassimp.so.3.0.1264)
==3284==    by 0x581E2B2: Assimp::Importer::ReadFile(char const*, unsigned int) (in /usr/lib/libassimp.so.3.0.1264)
==3284==    by 0x40D71A: glDetail::CMesh::CMesh(char const*) (Mesh.cpp:49)
==3284==    by 0x412FB5: _ZN9__gnu_cxx13new_allocatorIN8glDetail5CMeshEE9constructIS2_IRPKcEEEvPT_DpOT0_ (in /home/mattmatt/workspace/C++/alpha++/main-dev/eclipse/Alpha++/Debug/Alpha++)
==3284==    by 0x412E96: _ZNSt16allocator_traitsISaIN8glDetail5CMeshEEE12_S_constructIS1_IRPKcEEENSt9enable_ifIXsrSt6__and_IINS3_18__construct_helperIT_IDpT0_EE4typeEEE5valueEvE4typeERS2_PSB_DpOSC_ (alloc_traits.h:253)
==3284==    by 0x412D22: _ZNSt16allocator_traitsISaIN8glDetail5CMeshEEE9constructIS1_IRPKcEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS2_PT_DpOS8_ (alloc_traits.h:399)
==3284==    by 0x412B3C: std::_Sp_counted_ptr_inplace<glDetail::CMesh, std::allocator<glDetail::CMesh>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<char const*&>(std::allocator<glDetail::CMesh>, char const*&) (shared_ptr_base.h:515)
==3284==    by 0x412843: _ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceIN8glDetail5CMeshESaIS3_ELNS_12_Lock_policyE2EEE9constructIS6_IKS4_RPKcEEEvPT_DpOT0_ (in /home/mattmatt/workspace/C++/alpha++/main-dev/eclipse/Alpha++/Debug/Alpha++)
==3284==    by 0x41249F: _ZNSt16allocator_traitsISaISt23_Sp_counted_ptr_inplaceIN8glDetail5CMeshESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEEE12_S_constructIS6_IKS3_RPKcEEENSt9enable_ifIXsrSt6__and_IINS8_18__construct_helperIT_IDpT0_EE4typeEEE5valueEvE4typeERS7_PSH_DpOSI_ (alloc_traits.h:253)
==3284== 
==3284== LEAK SUMMARY:
==3284==    definitely lost: 7,862 bytes in 12 blocks
==3284==    indirectly lost: 0 bytes in 0 blocks
==3284==      possibly lost: 0 bytes in 0 blocks
==3284==    still reachable: 80,231 bytes in 759 blocks
==3284==         suppressed: 0 bytes in 0 blocks
==3284== Reachable blocks (those to which a pointer was found) are not shown.
==3284== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3284== 
==3284== For counts of detected and suppressed errors, rerun with: -v
==3284== Use --track-origins=yes to see where uninitialised values come from
==3284== ERROR SUMMARY: 13 errors from 8 contexts (suppressed: 0 from 0)

0 个答案:

没有答案