-1

My python script does connect to different ssh'es for like 1000 times, per python script run, also fetches web-pages, using requests.

What I'm using is subprocess, to execute ssh connection, and requests library, to fetch web-pages.

After that, when app finishes it's execution, I have +500Mb in RAM, moreover, while running, I've been logging resources, there are up to 15 Mb of resources, but takes in RAM/Swap about 500mb.

What can be causing that kind a problem?

Garbage Collector (gc.collect()) is not helping, everything is same.

Tried not to use global variables, delete used variables, which may be large-sized, nothing helps.

Sergey
  • 1
  • 1
  • how are you measuring this memory usage? – roippi Mar 21 '15 at 15:21
  • I'm watching free -m, or swapon -s, top, etc. Memory does increase only after script running. By the way, amount of processed connections of course, depends on size, RAM has increased to. In python, while logging, I've been measuring it using resource lib – Sergey Mar 21 '15 at 15:23
  • I ask because many people read the output of `free` incorrectly. Are you looking at the "mem" row or the "-/+ buffers/cache" row? You should be looking at the latter. – roippi Mar 21 '15 at 15:27
  • Yeah, I'm looking correctly, moreover, when RAM ends, it is noticeable, that swap is being used – Sergey Mar 21 '15 at 15:32
  • Your keeping references to data somewhere. Without code there is not much to say. – Daniel Mar 21 '15 at 15:59

1 Answers1

0

I've found solution, problem was, that dozens, hundreds of ssh processes were leaving in system. I've just executed killall sshpass, and everything is Okay :)

os.popen("killall sshpass")
Sergey
  • 1
  • 1