Python allocation memory error

I’m using a ConnectPortX8 to access 3 DIGI sensors (Watchport/T, Watchport/D and Watchport LTH). For each sensor I send a telnet request to ConnectPortX8 to run the relative python script.
The polling time is about 10 seconds.
After about a 5 hours test I obtain a Python error: Python is not able to allocate memory to import a zip file.
Then, I have to reboot the ConnectPortX8.
Python seems to not release all memory after the execution of the scripts.
Please find attached the 3 python scripts.
The python version is 2.4.3.

Please read this Python Wiki page:

The issue is that Python uses its own notion of when and how to free memory. So the Python objects remain “in use” until either you manually force garbage collection, or Python decides it is time to clean house.

As noted on this page, Python does NOT automatically force auto-collection when the X8 runs out of memory.

TCP sockets (either client or server) chew up tons of memory, so I would either force gc.collect() after ever socket close, or keep a counter and after ever “X” sockets are closed.