How do I free objects after the script execution? #455
-
I have set of scripts that produce and use objects like this:
If I comment the last line, rb seems not to be released automatically. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
Run:
I don't know how to do it automatically |
Beta Was this translation helpful? Give feedback.
-
AFAIR |
Beta Was this translation helpful? Give feedback.
-
The following code solves my issue. I hope it will be useful for someone else. I would also appreciate to receive any comments on this method, if it has mistakes or vulnerables.
|
Beta Was this translation helpful? Give feedback.
-
here is how to get globals w/o calculating 'globals()'
|
Beta Was this translation helpful? Give feedback.
-
also: you call GetPythonEngine 10 times. cache it to var. |
Beta Was this translation helpful? Give feedback.
-
also: |
Beta Was this translation helpful? Give feedback.
-
You can change your code to the following so that you do not pollute the main module dictionary. def dowork():
from pc1 import Pc as pc
rb = pc.ReceiptBuilder()
# work with receipt builder
dowork() |
Beta Was this translation helpful? Give feedback.
The following code solves my issue. I hope it will be useful for someone else.
fPyDelphiObjects - is a TDictionary<string, PPyObject>, where I keep all the P4D objects, that were created during script execution.
So this code is kinda my own garbage collector.
I would also appreciate to receive any comments on this method, if it has mistakes or vulnerables.