2

I have a python script (exe made with py2exe) that runs on several machines. This Python exe does two things periodically; one thread writes a py file for further treatment while another thread listens on a tcp port using the pyZmq module. The has run perfectly for days, using around 12Mo of ram.

Now here is the problem : these machines also run 3dsmax rendering. 3dsmax takes all available ram on the system, leaving only 4Mo of ram for my script. In this state, the reporting (py file writing) thread runs correctly, but the one that listens on the tcp port doesn't work anymore (sending msg to the machine don't get received).

However, this python exe process runs on high level priority :

set_nice(psutil.HIGH_PRIORITY_CLASS)

So, how can I reserve 14Mo of ram for my process, so that no other process running can take this ram ? Or another way to avoid the exe to 'give' his ram to other processes?

Thanks, Kib

xxmbabanexx
  • 8,256
  • 16
  • 40
  • 60
KiboOst
  • 43
  • 1
  • 4
  • There might be some good leads in [Set Windows process (or user) memory limit](http://stackoverflow.com/questions/192876/set-windows-process-or-user-memory-limit) – Octipi Feb 21 '13 at 11:07
  • Why do you think the low available RAM is causing the problem? Are you getting out of memory errors? Unless you have the virtual memory page file disabled it should not be a problem. – barracel Feb 25 '13 at 03:06

1 Answers1

0

You can use the Win32 call VirtualLock. I don't see any easy python examples, and don't have a windows machine handy to play around, but it might be relatively easy.

Outside of Python ProcessHacker seems like it might be able to do it, but I can't verify.

In general though, this is a bad idea. I think you may have a more serious issue going on. Good luck!

chmullig
  • 13,006
  • 5
  • 35
  • 52