MemMonitor.st
changeset 109 c23841df3616
parent 108 a936f81cc162
child 110 570a38362ae1
equal deleted inserted replaced
108:a936f81cc162 109:c23841df3616
    23 
    23 
    24 MemoryMonitor comment:'
    24 MemoryMonitor comment:'
    25  COPYRIGHT (c) 1991 by Claus Gittinger
    25  COPYRIGHT (c) 1991 by Claus Gittinger
    26 	      All Rights Reserved
    26 	      All Rights Reserved
    27 
    27 
    28 $Header: /cvs/stx/stx/libtool/Attic/MemMonitor.st,v 1.17 1995-07-23 03:19:24 claus Exp $
    28 $Header: /cvs/stx/stx/libtool/Attic/MemMonitor.st,v 1.18 1995-08-03 01:37:52 claus Exp $
    29 '!
    29 '!
    30 
    30 
    31 !MemoryMonitor class methodsFor:'documentation'!
    31 !MemoryMonitor class methodsFor:'documentation'!
    32 
    32 
    33 copyright
    33 copyright
    44 "
    44 "
    45 !
    45 !
    46 
    46 
    47 version
    47 version
    48 "
    48 "
    49 $Header: /cvs/stx/stx/libtool/Attic/MemMonitor.st,v 1.17 1995-07-23 03:19:24 claus Exp $
    49 $Header: /cvs/stx/stx/libtool/Attic/MemMonitor.st,v 1.18 1995-08-03 01:37:52 claus Exp $
    50 "
    50 "
    51 !
    51 !
    52 
    52 
    53 documentation
    53 documentation
    54 "
    54 "
    73 
    73 
    74 	t       tenure threshold
    74 	t       tenure threshold
    75 
    75 
    76 	I       incremental GC state
    76 	I       incremental GC state
    77 
    77 
       
    78 	weak    number of weak objects
       
    79 
    78 	rem     size of rememberedSet
    80 	rem     size of rememberedSet
    79 
    81 
    80 	minsc:  percent of newspace remaining after scavenge (worst case)
    82 	minsc:  percent of newspace remaining after scavenge (worst case)
    81 		(i.e. the minimum %% of scavenged objects)
    83 		(i.e. the minimum %% of scavenged objects)
    82 
    84 
    98 ! !
   100 ! !
    99 
   101 
   100 !MemoryMonitor class methodsFor:'defaults'!
   102 !MemoryMonitor class methodsFor:'defaults'!
   101 
   103 
   102 defaultExtent
   104 defaultExtent
   103     ^ (200 @ 250)
   105     ^ (200 @ 280)
   104 !
   106 !
   105 
   107 
   106 defaultLabel
   108 defaultLabel
   107     ^ 'Memory Monitor'
   109     ^ 'Memory Monitor'
   108 !
   110 !
   118 !MemoryMonitor methodsFor:'drawing'!
   120 !MemoryMonitor methodsFor:'drawing'!
   119 
   121 
   120 updateDisplay
   122 updateDisplay
   121     "update picture; trigger next update"
   123     "update picture; trigger next update"
   122 
   124 
   123     |total oldSpaceUsed newSpaceUsed freeMem 
   125     |total oldSpaceUsed newSpaceUsed freeMem oldSpaceSize
   124      gWidth shift scaleChange margin mustWait|
   126      gWidth shift scaleChange margin mustWait|
   125 
   127 
   126     shown ifTrue:[
   128     shown ifTrue:[
   127 	oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
   129 	oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
   128 	newSpaceUsed := ObjectMemory newSpaceUsed.
   130 	newSpaceUsed := ObjectMemory newSpaceUsed.
   129 	freeMem := ObjectMemory freeListSpace.
   131 	freeMem := ObjectMemory freeListSpace + (ObjectMemory oldSpaceSize - ObjectMemory oldSpaceUsed).
   130 	total := oldSpaceUsed + newSpaceUsed.
   132 	oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize.
       
   133 	total := oldSpaceSize + ObjectMemory newSpaceSize.
   131 
   134 
   132 	scaleChange := false.
   135 	scaleChange := false.
   133 
   136 
   134 	((total - freeMem) < minTotal) ifTrue:[
   137 	((total - freeMem) < minTotal) ifTrue:[
   135 	    minTotal := total - freeMem.
   138 	    minTotal := total - freeMem.
   138 	(total > maxTotal) ifTrue:[
   141 	(total > maxTotal) ifTrue:[
   139 	    maxTotal := total.
   142 	    maxTotal := total.
   140 	    scaleChange := true
   143 	    scaleChange := true
   141 	].
   144 	].
   142 
   145 
   143 	oldData at:updateIndex put:oldSpaceUsed.
   146 	oldData at:updateIndex put:oldSpaceSize. "/ oldSpaceUsed.
   144 	newData at:updateIndex put:newSpaceUsed.
   147 	newData at:updateIndex put:newSpaceUsed.
   145 	freeData at:updateIndex put:freeMem.
   148 	freeData at:updateIndex put:freeMem.
   146 	updateIndex := updateIndex + 1.
   149 	updateIndex := updateIndex + 1.
   147 
   150 
   148 	scaleChange ifTrue:[
   151 	scaleChange ifTrue:[
   179 	    mustWait := true.
   182 	    mustWait := true.
   180 	].
   183 	].
   181 
   184 
   182 	self updateLineX:(updateIndex - 1 + org - 1)
   185 	self updateLineX:(updateIndex - 1 + org - 1)
   183 		   total:total 
   186 		   total:total 
   184 		   old:oldSpaceUsed 
   187 		   old:oldSpaceSize "/ oldSpaceUsed
   185 		   new:newSpaceUsed 
   188 		   new:newSpaceUsed 
   186 		   free:freeMem.
   189 		   free:freeMem.
   187 
   190 
   188 	self updateNumbers.
   191 	self updateNumbers.
   189 	mustWait ifTrue:[
   192 	mustWait ifTrue:[
   248 
   251 
   249 	self updateNumbers.
   252 	self updateNumbers.
   250     ]
   253     ]
   251 !
   254 !
   252 
   255 
   253 updateLineX:x total:total old:oldSpaceUsed new:newSpaceUsed free:freeMem
   256 updateLineX:x total:total old:oldSpaceSize new:newSpaceUsed free:freeMem
   254     |hNew hOld hFree y1 y2|
   257     |hNew hOld hFree y1 y2 y3|
   255 
   258 
   256     hNew := (newSpaceUsed * scale) asInteger.
   259     hNew := (newSpaceUsed * scale) asInteger.
   257     hOld := (oldSpaceUsed * scale) // 2.
   260     hOld := (oldSpaceSize * scale) // 2.
   258     hFree := (freeMem * scale) asInteger.
   261     hFree := (freeMem * scale) // 2.
   259 
   262 
   260     y1 := height - 1.
   263     y1 := height - 1.
       
   264 
   261     y2 := y1 - hOld.
   265     y2 := y1 - hOld.
   262     self paint:oldColor.
   266     self paint:oldColor.
   263     self displayLineFromX:x y:y1 toX:x y:y2.
   267     self displayLineFromX:x y:y1 toX:x y:y2.
   264 
   268 
   265     y1 := y2.
   269     y3 := y1 - hFree.
   266     y2 := y1 - hFree.
       
   267     self paint:freeColor.
   270     self paint:freeColor.
   268     self displayLineFromX:x y:y1 toX:x y:y2.
   271     self displayLineFromX:x y:y1 toX:x y:y3.
   269 
   272 
   270     y1 := y2.
   273     y1 := y2 - hNew.
   271     y2 := y1 - hNew.
       
   272     self paint:newColor.
   274     self paint:newColor.
   273     self displayLineFromX:x y:y1 toX:x y:y2.
   275     self displayLineFromX:x y:y1 toX:x y:y2.
   274 !
   276 !
   275 
   277 
   276 updateNumbers
   278 updateNumbers
   285 	old:    current oldSpace in use
   287 	old:    current oldSpace in use
   286 	minsc:  percent of newspace remaining after scavenge (worst case)
   288 	minsc:  percent of newspace remaining after scavenge (worst case)
   287 	t       current tenure age
   289 	t       current tenure age
   288 	I       IGC state
   290 	I       IGC state
   289 	rem     remembered set size
   291 	rem     remembered set size
       
   292 	lrem    lifo remembered set size
   290 	count of scavenges
   293 	count of scavenges
   291 	last scavenge survivor rate
   294 	last scavenge survivor rate
   292     "
   295     "
   293 
   296 
   294     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 
   297     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 
   307     self paint:White on:Black.
   310     self paint:White on:Black.
   308 
   311 
   309     fontHeight := font height + font descent.
   312     fontHeight := font height + font descent.
   310     half := height // 2 + font descent.
   313     half := height // 2 + font descent.
   311 
   314 
   312     y := half - (fontHeight * 4).
   315     y := half - (fontHeight * 5).
   313 
   316 
   314     total ~~ prevTotal ifTrue:[
   317     total ~~ prevTotal ifTrue:[
   315 	((total - freeMem) < minTotal) ifTrue:[
   318 	((total - freeMem) < minTotal) ifTrue:[
   316 	    minTotal := total - freeMem.
   319 	    minTotal := total - freeMem.
   317 	].
   320 	].
   372     s := 't:' , (ObjectMemory tenureAge printStringLeftPaddedTo:2) , ' '.
   375     s := 't:' , (ObjectMemory tenureAge printStringLeftPaddedTo:2) , ' '.
   373     s := s , ' I:' , (ObjectMemory incrementalGCPhase printStringLeftPaddedTo:2) , ' '.
   376     s := s , ' I:' , (ObjectMemory incrementalGCPhase printStringLeftPaddedTo:2) , ' '.
   374     self displayOpaqueString:s x:0 y:y.
   377     self displayOpaqueString:s x:0 y:y.
   375 
   378 
   376     y := y + fontHeight.
   379     y := y + fontHeight.
       
   380     s := 'weak: ' , (ObjectMemory numberOfWeakObjects printStringLeftPaddedTo:4).
       
   381     self displayOpaqueString:s x:0 y:y.
       
   382 
       
   383     y := y + fontHeight.
   377     s := 'rem: ' , (ObjectMemory rememberedSetSize printStringLeftPaddedTo:5).
   384     s := 'rem: ' , (ObjectMemory rememberedSetSize printStringLeftPaddedTo:5).
       
   385     self displayOpaqueString:s x:0 y:y.
       
   386 
       
   387     y := y + fontHeight.
       
   388     s := 'lrem: ' , (ObjectMemory lifoRememberedSetSize printStringLeftPaddedTo:4 ifLarger:['****']).
   378     self displayOpaqueString:s x:0 y:y.
   389     self displayOpaqueString:s x:0 y:y.
   379 
   390 
   380 "/ does no longer make sense to show ....
   391 "/ does no longer make sense to show ....
   381 "/    y := y + fontHeight.
   392 "/    y := y + fontHeight.
   382 "/    ObjectMemory runsSingleOldSpace ifTrue:[
   393 "/    ObjectMemory runsSingleOldSpace ifTrue:[
   480 
   491 
   481     device ctrlDown ifTrue:[
   492     device ctrlDown ifTrue:[
   482 	labels :=    #(
   493 	labels :=    #(
   483 			'scavenge'
   494 			'scavenge'
   484 			'tenure'
   495 			'tenure'
       
   496 			'incremental collect'
   485 			'-'
   497 			'-'
   486 			'cleanup memory'
   498 			'cleanup memory'
   487 			'-'
   499 			'-'
   488 			'compress sources'
   500 			'compress sources'
   489 		      ).
   501 		      ).
   490 	selectors := #(
   502 	selectors := #(
   491 			scavenge
   503 			scavenge
   492 			tenure
   504 			tenure
       
   505 			incrementalCollect
   493 			nil
   506 			nil
   494 			cleanupMemory
   507 			cleanupMemory
   495 			nil
   508 			nil
   496 			compressSources
   509 			compressSources
   497 		      ).
   510 		      ).
   563 			    + ObjectMemory newSpaceSize.
   576 			    + ObjectMemory newSpaceSize.
   564 
   577 
   565     viewBackground := Black.
   578     viewBackground := Black.
   566 
   579 
   567     device hasColors ifTrue:[
   580     device hasColors ifTrue:[
   568 	newColor := Color yellow.
   581 	newColor := Color orange. "/ yellow.
   569 	freeColor := Color green.
   582 	freeColor := Color green.
   570 	oldColor := Color white.
   583 	oldColor := Color white.
   571     ] ifFalse:[
   584     ] ifFalse:[
   572 	newColor := Color grey:67.
   585 	newColor := Color grey:67.
   573 	freeColor := Color grey:33.
   586 	freeColor := Color grey:33.
   626 compressSources
   639 compressSources
   627     Smalltalk compressSources.
   640     Smalltalk compressSources.
   628     ObjectMemory markAndSweep
   641     ObjectMemory markAndSweep
   629 !
   642 !
   630 
   643 
       
   644 incrementalCollect
       
   645     [
       
   646 	[ObjectMemory gcStep] whileFalse:[(Delay forMilliseconds:1) wait]
       
   647     ] forkAt:Processor highestPriority
       
   648 !
       
   649 
   631 backgroundCollect
   650 backgroundCollect
   632     [ObjectMemory incrementalGC] forkAt:5 
   651     [ObjectMemory incrementalGC] forkAt:5 
   633 ! !
   652 ! !