Job Objects

[This is preliminary documentation and subject to change.]

A job object allows groups of processes to be managed as a unit. Job objects are namable, securable, sharable objects that control attributes of the processes associated with them. Operations performed on the job object affect all processes associated with the job object.

To create a job object, use the CreateJobObject function. When the job object is created, there are no associated processes. To associate a process with a job object, use the AssignProcessToJobObject function. After you associate a process with a job object, the association cannot be broken. In addition, all processes created by a process associated with the job object are also associated with the job object.

A job object can enforce limits on each associated process, such as the working set size, process priority, end-of-job time limit, and so on. To set limits for a job object, use the SetInformationJobObject function. If a process associated with a job object attempts to increase its working set size or process priority, the function calls are silently ignored.

The job object also records basic accounting information for all its associated processes, including those that have terminated. To retrieve this accounting information, use the QueryInformationJobObject function.

To terminate all processes currently associated with a job object, use the TerminateJobObject function.

To close a job object handle, use the CloseHandle function. The job object is destroyed when its last handle has been closed. If there are running processes still associated with the job object when it is destroyed, they will continue to run even after the job object is destroyed.