<div dir="ltr">Timothy,<div><br></div><div> I observe huge memory leak after this commit:</div><div><br></div><div><span style="font-family:monospace"><span style="font-weight:bold;color:rgb(84,84,255)">Direct leak of 648208 byte(s) in 3683 object(s) allocated from:</span><span style="color:rgb(0,0,0)"> </span><br> #0 0x7f3d72729800 in calloc (/usr/lib/clang/3.9.1/lib/linux/<a href="http://libclang_rt.asan-x86_64.so">libclang_rt.asan-x86_64.so</a>+0xf6800)<span style="color:rgb(24,24,178)"> </span><span style="color:rgb(0,0,0)"> </span><br> #1 0x7f3d64a4d114 in st_new_renderbuffer /home/bartek/Devel/mesa/src/mesa/state_tracker/st_cb_fbo.c:256:35 <br> #2 0x7f3d6373ff1a in _mesa_update_texture_renderbuffer /home/bartek/Devel/mesa/src/mesa/main/fbobject.c:449:12 <br> #3 0x7f3d6376be9f in set_texture_attachment /home/bartek/Devel/mesa/src/mesa/main/fbobject.c:517:4 <br> #4 0x7f3d637699e2 in _mesa_framebuffer_texture /home/bartek/Devel/mesa/src/mesa/main/fbobject.c:3251:10 <br> #5 0x7f3d6376c59c in framebuffer_texture_with_dims /home/bartek/Devel/mesa/src/mesa/main/fbobject.c:3322:4 <br> #6 0x7f3d6376c695 in _mesa_FramebufferTexture2D /home/bartek/Devel/mesa/src/mesa/main/fbobject.c:3340:4 <br> #7 0x7f3d63db99cd in _mesa_unmarshal_FramebufferTexture2D /home/bartek/Devel/mesa/src/mesa/main/marshal_generated.c:20078:4 <br> #8 0x7f3d63d50861 in _mesa_unmarshal_dispatch_cmd /home/bartek/Devel/mesa/src/mesa/main/marshal_generated.c:40838:7 <br> #9 0x7f3d63cd7634 in glthread_unmarshal_batch /home/bartek/Devel/mesa/src/mesa/main/glthread.c:64:14 <br> #10 0x7f3d63cd6f71 in _mesa_glthread_finish /home/bartek/Devel/mesa/src/mesa/main/glthread.c:276:10 <br> #11 0x7f3d63fd3444 in _mesa_marshal_GetIntegerv /home/bartek/Devel/mesa/src/mesa/main/marshal_generated.c:36059:4 <br> #12 0x53a2b2 (/usr/bin/glretrace+0x53a2b2) <br> #13 0x5b8bf3 (/usr/bin/glretrace+0x5b8bf3) <br> #14 0x40c48b (/usr/bin/glretrace+0x40c48b) <br> #15 0x40cbe9 (/usr/bin/glretrace+0x40cbe9) <br> #16 0x40ce91 (/usr/bin/glretrace+0x40ce91) <br> #17 0x7f3d720dd2e6 in start_thread (/usr/lib/libpthread.so.0+0x72e6)<br>
<br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 5, 2017 at 7:21 PM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 04/05/2017 05:06 AM, Timothy Arceri wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
42aaa548 changed the renderbuffer initialisation of RefCount from<br>
1 to 0.<br>
<br>
This is inconsitent with how we use RefCount elsewhere. Also every<br>
driver implementation of NewRenderbuffer() calls<br>
_mesa_init_renderbuffer() so its safe to set it there.<br>
---<br>
src/mesa/drivers/common/meta.c | 2 --<br>
src/mesa/main/fbobject.c | 1 -<br>
src/mesa/main/renderbuffer.c | 2 +-<br>
3 files changed, 1 insertion(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/common/meta<wbr>.c b/src/mesa/drivers/common/meta<wbr>.c<br>
index efbc934..f4c91ac 100644<br>
--- a/src/mesa/drivers/common/meta<wbr>.c<br>
+++ b/src/mesa/drivers/common/meta<wbr>.c<br>
@@ -3037,22 +3037,20 @@ decompress_texture_image(struc<wbr>t gl_context *ctx,<br>
ctx->Texture.Unit[ctx->Texture<wbr>.CurrentUnit].Sampler);<br>
<br>
/* Create/bind FBO/renderbuffer */<br>
if (decompress_fbo->fb == NULL) {<br>
decompress_fbo->rb = ctx->Driver.NewRenderbuffer(ct<wbr>x, 0xDEADBEEF);<br>
if (decompress_fbo->rb == NULL) {<br>
_mesa_meta_end(ctx);<br>
return false;<br>
}<br>
<br>
- decompress_fbo->rb->RefCount = 1;<br>
-<br>
decompress_fbo->fb = ctx->Driver.NewFramebuffer(ctx<wbr>, 0xDEADBEEF);<br>
if (decompress_fbo->fb == NULL) {<br>
_mesa_meta_end(ctx);<br>
return false;<br>
}<br>
<br>
_mesa_bind_framebuffers(ctx, decompress_fbo->fb, decompress_fbo->fb);<br>
_mesa_framebuffer_renderbuffer<wbr>(ctx, ctx->DrawBuffer, GL_COLOR_ATTACHMENT0,<br>
decompress_fbo->rb);<br>
}<br>
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c<br>
index 4d9a7b8..e52c1e3 100644<br>
--- a/src/mesa/main/fbobject.c<br>
+++ b/src/mesa/main/fbobject.c<br>
@@ -1309,21 +1309,20 @@ allocate_renderbuffer_locked(s<wbr>truct gl_context *ctx, GLuint renderbuffer,<br>
struct gl_renderbuffer *newRb;<br>
<br>
/* create new renderbuffer object */<br>
newRb = ctx->Driver.NewRenderbuffer(ct<wbr>x, renderbuffer);<br>
if (!newRb) {<br>
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);<br>
return NULL;<br>
}<br>
assert(newRb->AllocStorage);<br>
_mesa_HashInsertLocked(ctx->S<wbr>hared->RenderBuffers, renderbuffer, newRb);<br>
- newRb->RefCount = 1; /* referenced by hash table */<br>
<br>
return newRb;<br>
}<br>
<br>
<br>
static void<br>
bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)<br>
{<br>
struct gl_renderbuffer *newRb;<br>
GET_CURRENT_CONTEXT(ctx);<br>
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c<br>
index 53e0b74..1d24e9c 100644<br>
--- a/src/mesa/main/renderbuffer.c<br>
+++ b/src/mesa/main/renderbuffer.c<br>
@@ -36,21 +36,21 @@<br>
/**<br>
* Initialize the fields of a gl_renderbuffer to default values.<br>
*/<br>
void<br>
_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)<br>
{<br>
GET_CURRENT_CONTEXT(ctx);<br>
<br>
rb->ClassID = 0;<br>
rb->Name = name;<br>
- rb->RefCount = 0;<br>
+ rb->RefCount = 1;<br>
rb->Delete = _mesa_delete_renderbuffer;<br>
<br>
/* The rest of these should be set later by the caller of this function or<br>
* the AllocStorage method:<br>
*/<br>
rb->AllocStorage = NULL;<br>
<br>
rb->Width = 0;<br>
rb->Height = 0;<br>
rb->Depth = 0;<br>
<br>
</blockquote>
<br></div></div>
Reviewed-by: Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div>