Huge memory leak? [CLOSED]
-
On 07/11/2014 at 03:51, xxxxxxxx wrote:
Hi
I have a script project where I'm procedurally generating a high poly mesh - saving it to an external file, and then loading it in at render time, freeing up the editor to have only a low poly version of the mesh.However, for large models, I notice that when the program goes to regenerate another model - C4D seems to grind to a halt or crash. I'm wondering is there something I should be doing to free up memory, flush caches etc - or something to optimise the program.
Here's what the program does..
1. Generate high mesh, save it to an external doc, delete from current scene - keep low poly version.
2. When external rendering - load up doc with high poly version, clone and grab it, insert into scene passed to renderer. (After rendering - the doc that was passed to the renderer should disappear / free up its memory?)
3. Regenerate another model - C4D very slow or crashes. -
On 07/11/2014 at 04:03, xxxxxxxx wrote:
When do you load the file (in which method of your Plugin)?
And just btw, you do not need to clone the object if you're discarding
the document anyway. Just remove it from the loaded document and
you can insert it somewhere else without cloning.Best,
Niklas -
On 07/11/2014 at 04:27, xxxxxxxx wrote:
Hi
It's all running inside a Python tag actually.In the message function - I listen for when the external renderer has started and then load up the scene with the high poly model and insert it. All a bit messy I know.
If I don't clone the object when loading it in - the programs crashes out for some reason.
-
On 07/11/2014 at 04:33, xxxxxxxx wrote:
Regarding the cloning - it actually works without cloning when I've only one object - but when there's multiple objects it crashes - not sure if this related to the memory problem - here's my loading code..
path = "/Applications/MAXON/tempScene.c4d"
fO = c4d.documents.LoadDocument(path, c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS)olist = fO.SearchObject("Vecfield Final").GetChildren()
for o in olist:
clone = o.GetClone()
doc.InsertObject(clone, None, None) -
On 07/11/2014 at 06:18, xxxxxxxx wrote:
You must not make modifications to the scene structure from an expression. See
https://developers.maxon.net/forum/topic/7689/9710_create-userdata-solved&PID=42280#42280- Why not just insert the "Vecfield Final" object instead of each child separately?
- You should call o.Remove() if you're going to insert o, no need to clone it then.
But as already pointed out, don't make scene modifications from an expression.
-
On 07/11/2014 at 06:40, xxxxxxxx wrote:
Hello,
just to be sure: do you work with a Python Tag or do you work with a Python TagData plugin?
Best wishes,
Sebastian -
On 07/11/2014 at 06:52, xxxxxxxx wrote:
Yeah I know I shouldn't be messing with threads. But not sure what else to do. Is there a way with Python tags to detect when I've started a render, 'pause', make modifications i.e load in another model, continue the render and finish, then remove model afterwards.
-
On 07/11/2014 at 09:15, xxxxxxxx wrote:
and for whatever reason - I have to get the children rather than the parent node - or nothing happens - and if I don't clone the children I get this error
AssertionError: Found next objects. Please add them separately. -
On 07/11/2014 at 12:08, xxxxxxxx wrote:
Hi Glenn,
as Niklas mentioned in the other thread he linked to, the object must be freed from the loaded document, before inserting it to the new one.
I didn´t know that either!!
Thanks Niklas!
Regarding your problem :import c4d def main() : path = "/Users/monkeytack/Desktop/box/box.c4d" fO = c4d.documents.LoadDocument(path, c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS) olist = fO.SearchObject("Vectorfield").GetChildren() for obj in olist: TexTag=obj.GetTag(c4d.Ttexture) mat = TexTag[c4d.TEXTURETAG_MATERIAL] obj.Remove() doc.InsertObject(obj, None, None) if mat == None: pass else: doc.InsertMaterial(mat, checknames=False) c4d.EventAdd() if __name__=='__main__': main()
Best wishes
Martin -
On 07/11/2014 at 13:26, xxxxxxxx wrote:
Ahh yes thanks guys - removing the object before worked - that solved that problem..
But the crashing and memory problems persist - but not to worry I've decided to just simplify my project by having 2 separate modes - a preview mode, and a 'final' mode... rather than trying to switch between the 2 midway when rendering. I was just trying to be fancy, but playing with fire really when messing with internal code execution.
here's what I'm working on by the way..
http://glennmarshall.wordpress.com/2014/10/31/3d-neon-vector-fields/