I'm creating a chat daemon in python and twisted framework. And I'm wondering if I have to delete every variable create in my functions to save memory in the long run when multiple users are connected, or are those variable automatically clear?. Here's a strip down version of my code to illustrate my point:
class Chat(LineOnlyReceiver):
LineOnlyReceiver.MAX_LENGTH = 500
def lineReceived(self, data):
self.sendMessage(data)
def sendMessage(self, data):
try:
message = data.split(None,1)[1]
except IndexError:
return
self.factory.sendAll(message)
#QUESTION : do i have to delete message and date??????????????????
del message
del data
class ChatFactory(Factory):
protocol = Chat
def __init__(self):
self.clients = []
def addClient(self, newclient):
self.clients.append(newclient)
def delClient(self, client):
self.clients.remove(client)
def sendAll(self, message):
for client in self.clients:
client.transport.write(message + "\n")