Rocket U2 | UniVerse & UniData

 View Only
  • 1.  PyObject and memory management

    PARTNER
    Posted 07-27-2021 06:50
    Hello,

    I wonder how UNIBASIC manages memory allocated by python modules executed via pyCall which returns PYOBJECT. And especially if the memory is correctly restored at the exit of the programs and subroutines which instantiated these variables.

    Is anyone who knows ?

    ------------------------------
    Manu Fernandes
    ------------------------------


  • 2.  RE: PyObject and memory management

    ROCKETEER
    Posted 07-29-2021 09:45
    Edited by Mike Rajkowski 07-29-2021 09:45
    Manu,

    The BASIC variable that contains the PYOBJECT can be cleared, and the memory used by that object returned by setting the variable to "".

    Variables local to the subroutine ( not returned or in named common )  are cleaned up when you return from the subroutine.

    As for the behavior on exit, the default setting of REINIT.PYTHON is set to ON.  Which means that when a BASIC program finishes ( and returns to ECL/TCL )  the Python environment is reinitialized.   So the memory is restored at exit.

    Note that there are times that you may want/need to turn off REINIT.PYTHON, when this is done, the memory tied to BASIC variables will be released/restored, yet the Python environment will remain the same.

    ------------------------------
    Mike Rajkowski
    support
    Rocket Internal - All Brands
    DENVER CO United States
    ------------------------------