'From Squeak6.1alpha of 12 July 2022 [latest update: #22122] on 13 July 2022 at 11:00:14 am'! !SmalltalkImage methodsFor: 'memory space' stamp: 'mt 7/13/2022 10:58'! lowSpaceWatcher "Wait until the low space semaphore is signalled, then take appropriate actions." | free preemptedProcess | self garbageCollectMost <= self lowSpaceThreshold ifTrue: [self garbageCollect <= self lowSpaceThreshold ifTrue: ["free space must be above threshold before starting low space watcher" ^ Beeper beep]]. Smalltalk specialObjectsArray at: 23 put: nil. "process causing low space will be saved here" LowSpaceSemaphore := Semaphore new. self primLowSpaceSemaphore: LowSpaceSemaphore. self primSignalAtBytesLeft: self lowSpaceThreshold. "enable low space interrupts" LowSpaceSemaphore wait. "wait for a low space condition..." self primSignalAtBytesLeft: 0. "disable low space interrupts" self primLowSpaceSemaphore: nil. LowSpaceProcess := nil. "The process that was active at the time of the low space interrupt." preemptedProcess := Smalltalk specialObjectsArray at: 23. Smalltalk specialObjectsArray at: 23 put: nil. "Note: user now unprotected until the low space watcher is re-installed" self memoryHogs isEmpty ifFalse: [free := self bytesLeft. self memoryHogs do: [ :hog | hog freeSomeSpace ]. self bytesLeft > free ifTrue: [ ^ self installLowSpaceWatcher ]]. Preferences logDebuggerStackToFile ifTrue: [ self logError: 'Space is low' inContext: preemptedProcess suspendedContext to: 'LowSpaceDebug.log']. preemptedProcess debugWithTitle: 'Space is low' full: false contents: self lowSpaceChoices. ! ! !SmalltalkImage methodsFor: 'memory space' stamp: 'mt 7/13/2022 10:34'! signalLowSpace "Signal the low-space semaphore to alert the user that space is running low. Treat the active process as the culprit. See OutOfMemory and its uses." Smalltalk specialObjectsArray at: 23 put: Processor activeProcess. LowSpaceSemaphore signal.! !