--- a/MemoryMonitor.st Sat Mar 25 23:23:29 1995 +0100
+++ b/MemoryMonitor.st Sat Mar 25 23:24:57 1995 +0100
@@ -10,11 +10,12 @@
hereby transferred.
"
+'From Smalltalk/X, Version:2.10.5 on 22-mar-1995 at 7:43:35 am'!
+
StandardSystemView subclass:#MemoryMonitor
- instanceVariableNames:'updateInterval updateBlock myProcess oldData newData
- freeData updateIndex org maxTotal minTotal dX
- newColor freeColor oldColor
- prevTotal prevFree prevFree2 prevOld scale'
+ instanceVariableNames:'updateInterval updateBlock myProcess oldData newData freeData
+ updateIndex org maxTotal minTotal dX newColor freeColor oldColor
+ prevTotal prevFree prevFree2 prevOld scale'
classVariableNames:''
poolDictionaries:''
category:'Interface-Tools'
@@ -24,7 +25,7 @@
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.11 1995-03-09 03:31:23 claus Exp $
+$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.12 1995-03-25 22:24:28 claus Exp $
'!
!MemoryMonitor class methodsFor:'documentation'!
@@ -45,7 +46,7 @@
version
"
-$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.11 1995-03-09 03:31:23 claus Exp $
+$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.12 1995-03-25 22:24:28 claus Exp $
"
!
@@ -109,11 +110,84 @@
!MemoryMonitor methodsFor:'drawing'!
-redraw
- "redraw all"
+updateDisplay
+ "update picture; trigger next update"
+
+ |total oldSpaceUsed newSpaceUsed freeMem
+ gWidth shift scaleChange margin mustWait|
+
+ shown ifTrue:[
+ oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory fixSpaceUsed.
+ newSpaceUsed := ObjectMemory newSpaceUsed.
+ freeMem := ObjectMemory freeListSpace.
+ total := oldSpaceUsed + newSpaceUsed.
+
+ scaleChange := false.
+
+ ((total - freeMem) < minTotal) ifTrue:[
+ minTotal := total - freeMem.
+ scaleChange := true
+ ].
+ (total > maxTotal) ifTrue:[
+ maxTotal := total.
+ scaleChange := true
+ ].
+
+ oldData at:updateIndex put:oldSpaceUsed.
+ newData at:updateIndex put:newSpaceUsed.
+ freeData at:updateIndex put:freeMem.
+ updateIndex := updateIndex + 1.
+
+ scaleChange ifTrue:[
+ scale := height asFloat / (maxTotal + 100000).
+ self redraw
+ ].
+
+ gWidth := width - org.
+ margin := 1.
- self clear.
- self redrawX:0 y:0 width:width height:height
+ mustWait := false.
+ ((updateIndex-1) >= (gWidth - margin)) ifTrue:[
+"on slow displays, use:"
+"/ shift := gWidth // 4.
+
+"for smooth display, use:"
+ shift := 1.
+
+ oldData replaceFrom:1 with:oldData startingAt:shift+1.
+ newData replaceFrom:1 with:newData startingAt:shift+1.
+ freeData replaceFrom:1 with:freeData startingAt:shift+1.
+
+ updateIndex := updateIndex - shift.
+ dX := dX + shift.
+
+ self catchExpose.
+ self copyFrom:self
+ x:(org + shift) y:0
+ toX:org y:0
+ width:(gWidth - shift - margin)
+ height:height.
+ self clearRectangleX:(width - margin - shift) y:0
+ width:shift height:height.
+ mustWait := true.
+ ].
+
+ self updateLineX:(updateIndex - 1 + org - 1)
+ total:total
+ old:oldSpaceUsed
+ new:newSpaceUsed
+ free:freeMem.
+
+ self updateNumbers.
+ mustWait ifTrue:[
+ self waitForExpose.
+ ]
+
+ ].
+
+ updateBlock notNil ifTrue:[
+ Processor addTimedBlock:updateBlock afterSeconds:updateInterval
+ ].
!
redrawX:x y:y width:w height:h
@@ -300,84 +374,11 @@
self displayOpaqueString:s x:0 y:y.
!
-updateDisplay
- "update picture; trigger next update"
-
- |total oldSpaceUsed newSpaceUsed freeMem
- gWidth shift scaleChange margin mustWait|
-
- shown ifTrue:[
- oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory fixSpaceUsed.
- newSpaceUsed := ObjectMemory newSpaceUsed.
- freeMem := ObjectMemory freeListSpace.
- total := oldSpaceUsed + newSpaceUsed.
-
- scaleChange := false.
-
- ((total - freeMem) < minTotal) ifTrue:[
- minTotal := total - freeMem.
- scaleChange := true
- ].
- (total > maxTotal) ifTrue:[
- maxTotal := total.
- scaleChange := true
- ].
-
- oldData at:updateIndex put:oldSpaceUsed.
- newData at:updateIndex put:newSpaceUsed.
- freeData at:updateIndex put:freeMem.
- updateIndex := updateIndex + 1.
-
- scaleChange ifTrue:[
- scale := height asFloat / (maxTotal + 100000).
- self redraw
- ].
-
- gWidth := width - org.
- margin := 1.
+redraw
+ "redraw all"
- mustWait := false.
- ((updateIndex-1) >= (gWidth - margin)) ifTrue:[
-"on slow displays, use:"
-"/ shift := gWidth // 4.
-
-"for smooth display, use:"
- shift := 1.
-
- oldData replaceFrom:1 with:oldData startingAt:shift+1.
- newData replaceFrom:1 with:newData startingAt:shift+1.
- freeData replaceFrom:1 with:freeData startingAt:shift+1.
-
- updateIndex := updateIndex - shift.
- dX := dX + shift.
-
- self catchExpose.
- self copyFrom:self
- x:(org + shift) y:0
- toX:org y:0
- width:(gWidth - shift - margin)
- height:height.
- self clearRectangleX:(width - margin - shift) y:0
- width:shift height:height.
- mustWait := true.
- ].
-
- self updateLineX:(updateIndex - 1 + org - 1)
- total:total
- old:oldSpaceUsed
- new:newSpaceUsed
- free:freeMem.
-
- self updateNumbers.
- mustWait ifTrue:[
- self waitForExpose.
- ]
-
- ].
-
- updateBlock notNil ifTrue:[
- Processor addTimedBlock:updateBlock afterSeconds:updateInterval
- ].
+ self clear.
+ self redrawX:0 y:0 width:width height:height
! !
!MemoryMonitor methodsFor:'destroying'!
@@ -395,23 +396,6 @@
!MemoryMonitor methodsFor:'events'!
-keyPress:key x:x y:y
- key == $f ifTrue:[
- "faster"
- updateInterval := updateInterval / 2
- ].
- key == $s ifTrue:[
- "slower"
- updateInterval := updateInterval * 2
- ].
- key == $r ifTrue:[
- "reset max"
- maxTotal := prevTotal.
- scale := height asFloat / (maxTotal + 100000).
- self redraw.
- ]
-!
-
sizeChanged:how
|nn no nf delta oldSize newSize|
@@ -446,25 +430,69 @@
scale := height asFloat / (maxTotal + 100000).
self clear.
self redraw
+!
+
+keyPress:key x:x y:y
+ key == $f ifTrue:[
+ "faster"
+ updateInterval := updateInterval / 2
+ ].
+ key == $s ifTrue:[
+ "slower"
+ updateInterval := updateInterval * 2
+ ].
+ key == $r ifTrue:[
+ "reset max"
+ maxTotal := prevTotal.
+ scale := height asFloat / (maxTotal + 100000).
+ self redraw.
+ ]
! !
!MemoryMonitor methodsFor:'initialization'!
+memoryMenu
+ |labels selectors|
+
+ labels := #(
+ 'collect Garbage'
+ 'collect Garbage & compress'
+ '-'
+ 'background collect'
+ '-'
+ 'compress sources '
+ ).
+
+ selectors := #(
+ garbageCollect
+ compressingGarbageCollect
+ nil
+ backgroundCollect
+ nil
+ compressSources
+ ).
+
+ ^ PopUpMenu labels:(resources array:labels)
+ selectors:selectors
+ receiver:self
+!
+
realize
super realize.
updateBlock notNil ifTrue:[
- Processor addTimedBlock:updateBlock afterSeconds:updateInterval.
+ Processor addTimedBlock:updateBlock afterSeconds:updateInterval.
] ifFalse:[
- myProcess := [
- |d|
+ myProcess := [
+ |d|
- [true] whileTrue:[
- (Delay forSeconds:updateInterval) wait.
- self updateDisplay
- ]
- ] forkAt:6.
- myProcess name:'Memory Monitor [' ,
- Processor activeProcess id printString , '] update'
+ [true] whileTrue:[
+ (Delay forSeconds:updateInterval) wait.
+ self updateDisplay
+ ]
+ ] forkAt:6.
+ myProcess name:'monitor [' ,
+ Processor activeProcess id printString ,
+ '] update'
].
newColor := newColor on:device.
@@ -513,32 +541,6 @@
"
MemoryMonitor open
"
-!
-
-memoryMenu
- |labels selectors|
-
- labels := #(
- 'collect Garbage'
- 'collect Garbage & compress'
- '-'
- 'background collect'
- '-'
- 'compress sources '
- ).
-
- selectors := #(
- garbageCollect
- compressingGarbageCollect
- nil
- backgroundCollect
- nil
- compressSources
- ).
-
- ^ PopUpMenu labels:(resources array:labels)
- selectors:selectors
- receiver:self
! !
!MemoryMonitor methodsFor:'menu functions'!
@@ -551,11 +553,12 @@
ObjectMemory verboseGarbageCollect
!
-backgroundCollect
- [ObjectMemory incrementalGC] forkAt:5
-!
-
compressSources
Smalltalk compressSources.
ObjectMemory markAndSweep
+!
+
+backgroundCollect
+ [ObjectMemory incrementalGC] forkAt:5
! !
+