Python’s memory allocation and de-allocation method is automatic. The TLNetAPI implements memory management into Python garbage collection; users should not need to worry about memory management.
API Initialization and Un-initialization
The TLNetAPI will get initialized when the module is imported into Python. The un-initialization process is registered as module cleanup function. Usually the cleanup function is invoked when the module is out of scope or during the Python interpreter termination.
API Object Garbage Collection
Memory management for all API objects is integrated into Python garbage collection. The API object such as APITrace and APIPacket will be deleted and memory will be released when the object is out of scope. The cleanup function is registered as class __del__ function. Users can also use the del function to explicitly delete and release an object. To avoid exceptions in API object destructors when exiting a script, make sure to explicitly delete API objects before exiting.