[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesa3d-dev
Subject:    [Mesa3d-dev] [PATCH] [texenvprogram] Fix refcounting-related memory
From:       Nicolai =?iso-8859-1?q?H=E4hnle?= <nhaehnle () gmail ! com>
Date:       2008-05-31 22:17:31
Message-ID: 200806010017.31372.nhaehnle () gmail ! com
[Download RAW message or body]

[Mesa core hackers, please take a look. If there are no objections, I believe 
I should still have the access to commit this myself.
I noticed this memory leak with R300 when my machine died from excessive 
swapping in the glean/texCombine test...]

All newly created programs have RefCount == 1, but the fragment program cache
added an additional reference in cache_item, with the result being that none
of the programs were ever freed.

Solve the problem by not creating the additional reference in cache_item.
---
 src/mesa/main/texenvprogram.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 68a4db9..af19a38 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -1204,7 +1204,7 @@ static void cache_item( GLcontext *ctx,
    c->key = _mesa_malloc(sizeof(*key));
    memcpy(c->key, key, sizeof(*key));
 
-   _mesa_reference_fragprog(ctx, &c->data, prog);
+   c->data = prog;
 
    if (cache->n_items > cache->size * 1.5) {
       if (cache->size < 1000)
@@ -1271,6 +1271,7 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx )
 
          create_new_program(ctx, &key, newProg);
 
+         /* Our ownership of newProg is transferred to the cache */
          cache_item(ctx, &ctx->Texture.env_fp_cache, hash, &key, newProg);
       }
 
-- 
1.5.4.3


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic