From Appmethod Libraries
Jump to: navigation, search

Object Pascal

NeverSleepOnMMThreadContention: Boolean;


extern DELPHI_PACKAGE bool NeverSleepOnMMThreadContention;


Type Visibility Source Unit Parent
variable public
System System


Dictates memory manager behavior during a thread contention.

The Memory Manager is a shared resource, and when many threads in the application attempt to perform a memory operation at the same time, one or more threads may have to wait for a pending operation in another thread to complete before it can continue. This situation is called a thread contention. When a thread contention occurs inside the Memory Manager, the default behavior is to first give up the remaining time in the thread’s time slice. If the resource is still not available when the thread enters its next time slice, the Memory Manager calls the OS procedure Sleep before trying again.

This behavior works well on machines with single or dual core CPUs, and also when the ratio of the number of running threads to number of CPU cores is relatively high (greater than 2:1). In other situations, better performance can be obtained by entering a busy waiting loop until the resource becomes available. If NeverSleepOnMMThreadContention is True, the Memory Manager will use this alternate strategy when a thread contention occurs. The default value for NeverSleepOnMMThreadContention is False.

See Also