[Bf-python] Scriptlink memory link

Campbell Barton cbarton at metavr.com
Sun Oct 15 06:35:29 CEST 2006


Hey Ken, sorry was a bit of a low digg, I should explain..

The idea of having a new mesh deallocated  if never linked to an object 
seems fine, and it works in some cases.

however most of the cases where it would be useful to me, Im either 
using vertex groups, or some editmode tool
so I need to add in some function to manage creation  and removal of a 
dummy mesh, preferably one that can be reused between runs.

* define a name users probably wont use, say '~dummy_mesh~'
* try and get that mesh data from blender
* if its there make sure its got zero users
* else create it for the first time.
* every time the exporter finishes with it, set the me.verts= None

Im not that worried by this, its clunky but it works well enough.
however this isnt the first time a memory leak has been reported that 
was infact just mesh data not being free'd.

also, when newer users start scripting this and notice a memory leak, 
(Like Sapir)
its frustrating to explain that they'll need to work around it by adding 
a workaround thats about the same length as their script.
its also somthing that isnt a problem with NMesh, makign Mesh less 
attractive from a user POV.

Mesh.Unlink may not be the way to go, I just think it would make the 
solution more obvious but there could be better solutions.

- Cam


Campbell Barton wrote:
> Thats ok, but in this situation he's using vertex groups so it needs 
> to be assigned to an object,\
> also editnmode tools require it.
>
> Ken Hughes wrote:
>> Campbell Barton wrote:
>>> Its not a memory leak exactly, your making a new mesh each time the 
>>> script runs
>>> Ken hows about Mesh.Unlink() for zero user meshes?
>>
>> We've been over this many times on the list in in IRC.  If you don't 
>> want the mesh to be "permanent", don't assign it to an object.  If 
>> the mesh is created in the script with Mesh.New() and isn't linked to 
>> an object, then it should be freed when the object is deallocated. 
>> Otherwise it's subject to the Blender rules.
>>
>> Ken
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-python
>>
>
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list