I have some scripts that I suspect are leaking memory, as the project is very small but I have a number of scripts running on tag value change events and memory is slowly but surely increasing until it crashes. My value change scripts most likely should be moved into gw tag change events due to their execution time (I will time them and check their execution speed and their execution frequency), but I was wondering how I can catch these leaks?
Python is garbage collected, so I would expect any script that successfully "finishes" to not be a problem. Perhaps there are scripts running, doing big blocking reads, that don't finish before new ones start and the number of running scripts just adds up?
On the gateway webpage under Status/Threads, you can grab a thread dump and possibly get some idea of whether what I described is the case...
Turn off the suspects for long enough to see if the problem stops growing.
If you cannot do that, VisualVM profiling combined with heap dumps. But be aware that such profile can cause breakage on its own--it is very invasive and can cause pathological execution pauses.