Object plugin hangs when IRR is on
rui_mac last edited by rui_mac
I can't even know what type of information I can provide to start solving this.
My Object plugin is working fine and producing the correct mesh.
When I perform a render in the window or in the Picture Viewer, everything is fine.
But, as I turn on Interactive Render Region, Cinema 4D hangs.
What could cause this?
rui_mac last edited by
The difference in this Object plugin is that I create two temporary documents with IsolateObjects(), and after getting the required objects created in the new temporary documents, I KillDocument() both at the end.
Could this be it?
maxon last edited by
Hi rui_mac, thanks for reaching out us.
With regard to the issue reported, I'm a bit surprised to see c4d.documents.KillDocument() executed considering the way garbage collection is handled in Python (i.e. you don't have to take care of freeing memory - if not on very explicit cases - since Python does it automatically)
Nevertheless, if you could provide us with a simple code to reproduce the issue we could get a better understanding of the cause.
rui_mac last edited by
I removed the KillDocument() and the IRR works now. So, it was the culprit.
I had added the KillDocument() because if some hangs when testing the code that seemed like some memory leaks and I since I didn't know that python performed automatic garbage collection, I was trying to delete everything that I created in my code.
I remember, back in COFFEE that I could perform a manual gc()
So, this is done automatically in python? Good to know.
As the code is working fine now, I consider this as solved.
I will test some more to see if the previous crashes are repeatable.
Thank you, Riccardo.
ferdinand last edited by ferdinand
reading this thread one question popped into my mind. You wrote:
I create two temporary documents with IsolateObjects(), and after getting the required objects created in the new temporary documents, I KillDocument() both at the end.
What do you mean by 'get'? If this means just referencing the objects this might explain your problems, depending on what you are doing with the objects. If you pass the object references as part of the results of your
GVOand also free the resources of these temporary documents, you are passing objects that might be dead references at the time of rendering, giving an explanation for your problems.
Also: When you just remove the resource freeing of your temporary documents, I do not think that they will be freed automatically by Python's garbage collector. The reason is: While the reference count for these document objects (objects referring here to the Python type) is zero after the scope of
GVOhas closed (making them candidates for collection) the referenced output objects (here referring to the Cinema type) are still alive and they do reference these document objects. Which would cause your temporary document objects to stay in memory. Which would not be too bad, since it would always be just the two documents and not an incrementally increasing amount, a.k.a a memory leak.
Long story short: Clone your objects if you want to pass them as the output and flush the documents afterwards to make things easy for Pythons gc (which is one of the main reasons why Python tends to be bloaty/slow).