Memery limitation for process

Welcome Forums General PowerShell Q&A Memery limitation for process

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 3 months ago.

  • Author
  • #54885

    Points: 0
    Rank: Member

    Hi All,
    i want to ask how can i set the the process like Spoolsv.exe to have maximum of 1GB Memory usage and if it increases above 1GB, the Spool service get restarted.

    Any Idea.

  • #54887

    Points: 0
    Rank: Member

    Since you posted this in a PowerShell forum, I will assume you are wanting to have a scripted solution to monitor the process.

    You can use get-process to monitor the process and it's current memory usage, then if member is above the declared value you can use restart-service to restart the service.

    You can set the process in an infinite loop so it will continuously run. Would recommend sleeping if doing this to keep from chewing up resources. Or you could make it a once through script that kicks off periodically using a scheduled task.

    Those are my thoughts.

The topic ‘Memery limitation for process’ is closed to new replies.