I'll start with my goal. I have a program, which establishes connection to some servers, database, etc. During the initialization it receives appropriate credentials and establishes the connections. The credentials get passed in some configuration format (lets say json). This is only used at the initialization, and plaintext credentials are then thrown away and do not need to be used ever again.
Now as to my question, how do i enforce cleaning up memory that contained these plaintext credentials? This includes zeroing the memory, and removing all references. Simple deletion of variable won't be enough, if another reference in the code survives. Is there a method that is "idiot-proof"? Meaning, even if some references survived, they will point to cleaned up data.
The program in question runs on Python 3.8 and can the solution can assume CPython.