Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Object plugin hangs when IRR is on

    Cinema 4D SDK
    python r20
    3
    5
    659
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      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?

      1 Reply Last reply Reply Quote 0
      • R
        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?

        1 Reply Last reply Reply Quote 0
        • maxonM
          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.

          Riccardo

          1 Reply Last reply Reply Quote 0
          • R
            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.

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by ferdinand

              Hi,

              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 GVO and 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 GVO has 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).

              Cheers
              zipit

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 1
              • First post
                Last post