Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Make clean-up after script

    Cinema 4D SDK
    python
    3
    3
    490
    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.
    • I
      iluxa7k
      last edited by iluxa7k

      Hello
      I'm working with pyside2.
      How to invoke clean-up methods in c4d enviroment?
      For example, i made app and if close it or check visibilty,then del app

      from PySide2.QtWidgets import QApplication
      
      app = QApplication.instance()
      // steps with dialogs
      if win.isVisible() == False:
         del app
      

      clean objects, any garbage collection in memory

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

        Hi,

        to my knowledge, there is nothing special going on in this regard with Cinema's Python interpreter. Also note that invoking del does technically not enforce an object to be garbage collected even in the most of vanilla Python interpreters. It simply removes a reference to an object from the current scope. If the reference count for that object is then zero on the next collection cycle, it might be collected. Even if you have just one reference to an object and you remove that reference, it might still linger in memory for quite a while after that. Long story short: You cannot really enforce the deallocation of memory in Python.

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • r_giganteR
          r_gigante
          last edited by

          Hi @iluxa7k thanks for reaching out us.

          With regard to your question, as already pointed out by @zipit , the Python del statement just is only responsible for decrementing the reference counter for the instance being "deleted" and not to actually free the memory used by the instance itself. This is clearly noted in the official Python documentation on the Note coming along with object.__del__(self) in Python 3 or object.__del__(self) in Python 2 .
          Given that, also consider that the del app statement you've described in your first post might not actually deliver the "clean-up" action you're thinking about.

          Best, Riccardo

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