diff options
author | George Marques <george@gmarqu.es> | 2017-06-15 23:08:45 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 23:08:45 -0300 |
commit | 7a8a789364e257ade9af10c292a253ecfc1f1ecf (patch) | |
tree | 7201f8526617e2ff065c6d468092d6ddb38fd545 | |
parent | 43a84429ff2fb0ba120f38797dcf313370b3bd18 (diff) | |
parent | 4dbe0967d5fb99a57786649ad9a00785e5fcb621 (diff) |
Merge pull request #9204 from Zylann/fix_mesh_poolvector_leak
Fixed memory leaks
-rw-r--r-- | core/dvector.h | 8 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/core/dvector.h b/core/dvector.h index 2e951b9661..4584a300f9 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -92,6 +92,7 @@ class PoolVector { // ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all + // Refcount should not be zero, otherwise it's a misuse of COW if (alloc->refcount.get() == 1) return; //nothing to do @@ -216,7 +217,12 @@ class PoolVector { { int cur_elements = alloc->size / sizeof(T); - Write w = write(); + + // Don't use write() here because it could otherwise provoke COW, + // which is not desirable here because we are destroying the last reference anyways + Write w; + // Reference to still prevent other threads from touching the alloc + w._ref(alloc); for (int i = 0; i < cur_elements; i++) { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index a38e149aff..ff483a0fde 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3107,6 +3107,7 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface) { } glDeleteVertexArrays(1, &surface->array_id); + glDeleteVertexArrays(1, &surface->instancing_array_id); for (int i = 0; i < surface->blend_shapes.size(); i++) { |