[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26869] trunk/blender: fix for memory leak : node animation data wasnt being free'd

Campbell Barton ideasman42 at gmail.com
Mon Feb 15 09:07:58 CET 2010


Hey Aligorith, I'll have a go at fixing this, otherwise I'll comment
out with some warning/printf that memory is being leaked and the bug
is known.

On Mon, Feb 15, 2010 at 2:41 AM, Joshua Leung <aligorith at gmail.com> wrote:
> Hi Campbell,
>
> This fix causes problems with animated nodes.
>
> The bugreport from venomgfx:
> "open blender > Shift+F3 > IKEY over the alpha slider, click anywhere..
> crash"  (this is on the output node)
>
> >From what I remember from trying to fix some bugs with the active node
> getting deselected/cleared immediately after being set, the problem is that
> a copy of the entire nodetree is made for every thread that does
> threaded/background compositing. This is results in many unpredicted
> consequences for the node API functions, such as this one.
>
> I'm not entirely sure what's going on here in this case though. Looks like
> the copying of animdata isn't happening (despite that being supposedly done
> on libblock level). For now, any users with this problem should just comment
> out the fix/changes here in node.c.
>
>
> Anyways, this is just a heads-up about this problem. I could investigate
> this further if the schedule over at the BI is too tight, otherwise, this'll
> have to wait till I get a few other pending issues sorted first :)
>
> Regards,
> Aligorith
>
> On Sun, Feb 14, 2010 at 2:38 AM, Campbell Barton <ideasman42 at gmail.com>wrote:
>
>> Revision: 26869
>>
>> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26869
>> Author:   campbellbarton
>> Date:     2010-02-13 14:38:10 +0100 (Sat, 13 Feb 2010)
>>
>> Log Message:
>> -----------
>> fix for memory leak: node animation data wasnt being free'd
>>
>> also some corrections to memory debug stuff.
>>
>> Modified Paths:
>> --------------
>>    trunk/blender/intern/guardedalloc/intern/mallocn.c
>>    trunk/blender/source/blender/blenkernel/intern/node.c
>>    trunk/blender/source/blender/blenloader/intern/readfile.c
>>
>> Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
>> ===================================================================
>> --- trunk/blender/intern/guardedalloc/intern/mallocn.c  2010-02-13 13:17:15
>> UTC (rev 26868)
>> +++ trunk/blender/intern/guardedalloc/intern/mallocn.c  2010-02-13 13:38:10
>> UTC (rev 26869)
>> @@ -305,9 +305,9 @@
>>                        memset(memh+1, 255, len);
>>
>>  #ifdef DEBUG_MEMCOUNTER
>> -               memh->_count= _mallocn_count++;
>>                if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
>>                        memcount_raise("MEM_mallocN");
>> +               memh->_count= _mallocn_count++;
>>  #endif
>>                return (++memh);
>>        }
>> @@ -330,9 +330,9 @@
>>                make_memhead_header(memh, len, str);
>>                mem_unlock_thread();
>>  #ifdef DEBUG_MEMCOUNTER
>> -               memh->_count= _mallocn_count++;
>>                if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
>>                        memcount_raise("MEM_callocN");
>> +               memh->_count= _mallocn_count++;
>>  #endif
>>                return (++memh);
>>        }
>> @@ -372,9 +372,9 @@
>>                mmap_in_use += len;
>>                mem_unlock_thread();
>>  #ifdef DEBUG_MEMCOUNTER
>> -               memh->_count= _mallocn_count++;
>>                if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
>>                        memcount_raise("MEM_mapallocN");
>> +               memh->_count= _mallocn_count++;
>>  #endif
>>                return (++memh);
>>        }
>>
>> Modified: trunk/blender/source/blender/blenkernel/intern/node.c
>> ===================================================================
>> --- trunk/blender/source/blender/blenkernel/intern/node.c       2010-02-13
>> 13:17:15 UTC (rev 26868)
>> +++ trunk/blender/source/blender/blenkernel/intern/node.c       2010-02-13
>> 13:38:10 UTC (rev 26869)
>> @@ -57,6 +57,7 @@
>>  #include "BKE_texture.h"
>>  #include "BKE_text.h"
>>  #include "BKE_utildefines.h"
>> +#include "BKE_animsys.h" /* BKE_free_animdata only */
>>
>>  #include "BLI_math.h"
>>  #include "BLI_blenlib.h"
>> @@ -1343,6 +1344,8 @@
>>
>>        ntreeEndExecTree(ntree);        /* checks for if it is still
>> initialized */
>>
>> +       BKE_free_animdata((ID *)ntree);
>> +
>>        BLI_freelistN(&ntree->links);   /* do first, then unlink_node goes
>> fast */
>>
>>        for(node= ntree->nodes.first; node; node= next) {
>>
>> Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
>> ===================================================================
>> --- trunk/blender/source/blender/blenloader/intern/readfile.c   2010-02-13
>> 13:17:15 UTC (rev 26868)
>> +++ trunk/blender/source/blender/blenloader/intern/readfile.c   2010-02-13
>> 13:38:10 UTC (rev 26869)
>> @@ -5307,7 +5307,7 @@
>>
>>        while(bhead && bhead->code==DATA) {
>>                void *data;
>> -#if 0
>> +#if 0
>>                /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded
>> malloc errors */
>>                short *sp= fd->filesdna->structs[bhead->SDNAnr];
>>                char *allocname = fd->filesdna->types[ sp[0] ];
>> @@ -5315,8 +5315,9 @@
>>
>>                strcpy(tmp, allocname);
>>                data= read_struct(fd, bhead, tmp);
>> +#else
>> +               data= read_struct(fd, bhead, allocname);
>>  #endif
>> -               data= read_struct(fd, bhead, allocname);
>>
>>                if (data) {
>>                        oldnewmap_insert(fd->datamap, bhead->old, data, 0);
>>
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
- Campbell


More information about the Bf-committers mailing list