MemoryMonitor.st
changeset 696 b55f8705bb41
parent 517 cc3d4e0fc758
child 735 600fe3dab131
equal deleted inserted replaced
695:bb9142257343 696:b55f8705bb41
    17 	classVariableNames:''
    17 	classVariableNames:''
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Interface-Tools'
    19 	category:'Interface-Tools'
    20 !
    20 !
    21 
    21 
    22 !MemoryMonitor class methodsFor:'documentation'!
    22 !MemoryMonitor  class methodsFor:'documentation'!
    23 
    23 
    24 copyright
    24 copyright
    25 "
    25 "
    26  COPYRIGHT (c) 1991 by Claus Gittinger
    26  COPYRIGHT (c) 1991 by Claus Gittinger
    27 	      All Rights Reserved
    27 	      All Rights Reserved
    51         frl     free space in (fragmented) free lists
    51         frl     free space in (fragmented) free lists
    52         fre     compact free area above the used oldSpace
    52         fre     compact free area above the used oldSpace
    53 
    53 
    54         old     current oldSpace in use
    54         old     current oldSpace in use
    55 
    55 
       
    56         cod     dynamic compiled code space size (just in time compiler)
       
    57 
    56         max,    extreme values of 'tot' since the monitor started
    58         max,    extreme values of 'tot' since the monitor started
    57         min     (can be reset by typing 'r' in the view)
    59         min     (can be reset by typing 'r' in the view)
    58 
    60 
    59         t       tenure threshold
    61         t       tenure threshold (1 .. 30)
    60 
    62 
    61         I       incremental GC state
    63         I       incremental GC state (2 = idle)
    62 
    64 
    63         weak    number of weak objects
    65         weak    number of weak objects
    64 
    66 
    65         rem     size of rememberedSet
    67         rem     size of rememberedSet
    66 
    68 
    72         %       percentage of live objects in newSpace after last scavenge
    74         %       percentage of live objects in newSpace after last scavenge
    73                 (i.e. this is the garbage vs. living objects ratio of
    75                 (i.e. this is the garbage vs. living objects ratio of
    74                  newSpace objects after the last scavenge)
    76                  newSpace objects after the last scavenge)
    75 
    77 
    76     the graphic shows:
    78     the graphic shows:
    77         yellow  newSpace used
    79         orange  newSpace used
    78         green   free memory in freeLists
    80         green   free memory in freeLists
    79         white   oldSpace used
    81         white   oldSpace used
    80 
    82 
    81 
    83 
    82     the popupMenu offers GC functions; keyboard options are:
    84     the popupMenu offers GC functions; keyboard options are:
    89         ObjectMemory
    91         ObjectMemory
    90         MemoryUsageMonitor ProcessMonitor
    92         MemoryUsageMonitor ProcessMonitor
    91 "
    93 "
    92 ! !
    94 ! !
    93 
    95 
    94 !MemoryMonitor class methodsFor:'defaults'!
    96 !MemoryMonitor  class methodsFor:'defaults'!
    95 
    97 
    96 defaultExtent
    98 defaultExtent
    97     ^ (200 @ 280)
    99     ^ (200 @ 320)
       
   100 
       
   101     "Modified: 24.8.1996 / 12:04:21 / cg"
    98 !
   102 !
    99 
   103 
   100 defaultIcon
   104 defaultIcon
   101     |i|
   105     |i|
   102 
   106 
   291 !
   295 !
   292 
   296 
   293 updateNumbers
   297 updateNumbers
   294     "redraw numbers.
   298     "redraw numbers.
   295      The values shown are:
   299      The values shown are:
   296 	max:    maximum memory used since monitor started
   300         max:    maximum memory used since monitor started
   297 	min:    minimum memory used since monitor started
   301         min:    minimum memory used since monitor started
   298 	tot:    total memory used (overall oldSpace + overall newSpace)
   302         tot:    total memory used (overall oldSpace + overall newSpace)
   299 	all:    current memory in use (oldSpace + newSpace)
   303         all:    current memory in use (oldSpace + newSpace)
   300 	new:    current newSpace in use
   304         new:    current newSpace in use
   301 	free:   current size of freelist in oldSpace
   305         free:   current size of freelist in oldSpace
   302 	old:    current oldSpace in use
   306         old:    current oldSpace in use
   303 	t:      current tenure age
   307         t:      current tenure age
   304 	I:      IGC state
   308         I:      IGC state
   305 	weak:   number of weak arrays in the system
   309         weak:   number of weak arrays in the system
   306 	rem     remembered set size
   310         rem     remembered set size
   307 	lrem    lifo remembered set size
   311         lrem    lifo remembered set size
   308 	minsc:  percent of newspace remaining after scavenge (worst case)
   312         minsc:  percent of newspace remaining after scavenge (worst case)
   309 	irq:    max. interrupt delay
   313         irq:    max. interrupt delay
   310 	count of scavenges / last scavenge survivor rate
   314         count of scavenges / last scavenge survivor rate
   311 
   315 
   312     "
   316     "
   313 
   317 
   314     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 
   318     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 
   315      y half s fontHeight total n|
   319      y half s fontHeight total n|
   330     half := height // 2 + font descent.
   334     half := height // 2 + font descent.
   331 
   335 
   332     y := half - (fontHeight * 5).
   336     y := half - (fontHeight * 5).
   333 
   337 
   334     total ~~ prevTotal ifTrue:[
   338     total ~~ prevTotal ifTrue:[
   335 	((total - freeMem) < minTotal) ifTrue:[
   339         ((total - freeMem) < minTotal) ifTrue:[
   336 	    minTotal := total - freeMem.
   340             minTotal := total - freeMem.
   337 	].
   341         ].
   338 	(total > maxTotal) ifTrue:[
   342         (total > maxTotal) ifTrue:[
   339 	    maxTotal := total.
   343             maxTotal := total.
   340 	].
   344         ].
   341 
   345 
   342 	s := 'max ' , ((maxTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
   346         s := 'max ' , ((maxTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
   343 	self displayOpaqueString:s x:0 y:font ascent.
   347         self displayOpaqueString:s x:0 y:font ascent.
   344 
   348 
   345 	s := 'min ' , ((minTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
   349         s := 'min ' , ((minTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
   346 	self displayOpaqueString:s x:0 y:(height - font descent).
   350         self displayOpaqueString:s x:0 y:(height - font descent).
   347 
   351 
   348 	s := 'tot ' , ((total  // 1024) printStringLeftPaddedTo:5) , 'k '.
   352         s := 'tot ' , ((total  // 1024) printStringLeftPaddedTo:5) , 'k '.
   349 	self displayOpaqueString:s x:0 y:y.
   353         self displayOpaqueString:s x:0 y:y.
   350 
   354 
   351 	prevTotal := total.
   355         prevTotal := total.
   352     ].
   356     ].
   353 
   357 
   354     y := y + fontHeight.
   358     y := y + fontHeight.
   355     s := 'all ' , ((memUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
   359     s := 'all ' , ((memUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
   356     self displayOpaqueString:s x:0 y:y.
   360     self displayOpaqueString:s x:0 y:y.
   360     s := 'new ' , ((newMemUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
   364     s := 'new ' , ((newMemUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
   361     self displayOpaqueString:s x:0 y:y.
   365     self displayOpaqueString:s x:0 y:y.
   362 
   366 
   363     y := y + fontHeight.
   367     y := y + fontHeight.
   364     freeMem ~~ prevFree ifTrue:[
   368     freeMem ~~ prevFree ifTrue:[
   365 	self paint:freeColor.
   369         self paint:freeColor.
   366 	s := 'frl ' , ((freeMem // 1024) printStringLeftPaddedTo:5) , 'k '.
   370         s := 'frl ' , ((freeMem // 1024) printStringLeftPaddedTo:5) , 'k '.
   367 	self displayOpaqueString:s x:0 y:y.
   371         self displayOpaqueString:s x:0 y:y.
   368 	prevFree := freeMem.
   372         prevFree := freeMem.
   369     ].
   373     ].
   370 
   374 
   371     y := y + fontHeight.
   375     y := y + fontHeight.
   372     free2 ~~ prevFree2 ifTrue:[
   376     free2 ~~ prevFree2 ifTrue:[
   373 	self paint:freeColor.
   377         self paint:freeColor.
   374 	s := 'fre ' , ((free2 // 1024) printStringLeftPaddedTo:5) , 'k '.
   378         s := 'fre ' , ((free2 // 1024) printStringLeftPaddedTo:5) , 'k '.
   375 	self displayOpaqueString:s x:0 y:y.
   379         self displayOpaqueString:s x:0 y:y.
   376 	prevFree2 := free2.
   380         prevFree2 := free2.
   377     ].
   381     ].
   378 
   382 
   379     y := y + fontHeight.
   383     y := y + fontHeight.
   380     (oldMemUsed - freeMem) ~~ prevOld ifTrue:[
   384     (oldMemUsed - freeMem) ~~ prevOld ifTrue:[
   381 	self paint:oldColor.
   385         self paint:oldColor.
   382 	s := 'old ' , (((oldMemUsed - freeMem) // 1024) printStringLeftPaddedTo:5) , 'k '.
   386         s := 'old ' , (((oldMemUsed - freeMem) // 1024) printStringLeftPaddedTo:5) , 'k '.
   383 	self displayOpaqueString:s x:0 y:y.
   387         self displayOpaqueString:s x:0 y:y.
   384 	prevOld := (oldMemUsed - freeMem).
   388         prevOld := (oldMemUsed - freeMem).
       
   389     ].
       
   390 
       
   391     ObjectMemory supportsJustInTimeCompilation ifTrue:[
       
   392         y := y + fontHeight.
       
   393         self paint:oldColor.
       
   394         n := ObjectMemory compiledCodeSpaceUsed.
       
   395         n > 9999 ifTrue:[
       
   396             s := 'cod ' , ((n // 1024) printStringLeftPaddedTo:5) , 'k'.
       
   397         ] ifFalse:[
       
   398             s := 'cod ' , (n printStringLeftPaddedTo:5) , ' '.
       
   399         ].
       
   400         self displayOpaqueString:s x:0 y:y.
   385     ].
   401     ].
   386 
   402 
   387     "
   403     "
   388      the following is internal - normally only interesting when debugging the VM
   404      the following is internal - normally only interesting when debugging the VM
   389     "
   405     "
   418     self displayOpaqueString:s x:0 y:y.
   434     self displayOpaqueString:s x:0 y:y.
   419 
   435 
   420     y := y + fontHeight.
   436     y := y + fontHeight.
   421     n := ObjectMemory maxInterruptLatency.
   437     n := ObjectMemory maxInterruptLatency.
   422     n notNil ifTrue:[
   438     n notNil ifTrue:[
   423 	s := 'irq ', (n printStringLeftPaddedTo:3) , ' ms'.
   439         s := 'irq ', (n printStringLeftPaddedTo:3) , ' ms'.
   424     ] ifFalse:[
   440     ] ifFalse:[
   425 	s := ''
   441         s := ''
   426     ].
   442     ].
   427     self displayOpaqueString:s x:0 y:y.
   443     self displayOpaqueString:s x:0 y:y.
   428 
   444 
   429     y := y + fontHeight.
   445     y := y + fontHeight.
   430     n := ObjectMemory lastScavengeReclamation / ObjectMemory newSpaceSize * 100.0.
   446     n := ObjectMemory lastScavengeReclamation / ObjectMemory newSpaceSize * 100.0.
   431     n := 100 - n asInteger.
   447     n := 100 - n asInteger.
   432     s := (ObjectMemory scavengeCount printStringLeftPaddedTo:6)
   448     s := (ObjectMemory scavengeCount printStringLeftPaddedTo:6)
   433 	 , (n printStringLeftPaddedTo:3) , '%'.
   449          , (n printStringLeftPaddedTo:3) , '%'.
   434     self displayOpaqueString:s x:0 y:y.
   450     self displayOpaqueString:s x:0 y:y.
   435 
   451 
   436     "Created: 7.11.1995 / 14:48:16 / cg"
   452     "Created: 7.11.1995 / 14:48:16 / cg"
       
   453     "Modified: 24.8.1996 / 11:57:22 / cg"
   437 ! !
   454 ! !
   438 
   455 
   439 !MemoryMonitor methodsFor:'events'!
   456 !MemoryMonitor methodsFor:'events'!
   440 
   457 
   441 keyPress:key x:x y:y
   458 keyPress:key x:x y:y
   749      (this is for debugging only - the system does this automatically)"
   766      (this is for debugging only - the system does this automatically)"
   750 
   767 
   751     ObjectMemory tenure
   768     ObjectMemory tenure
   752 ! !
   769 ! !
   753 
   770 
   754 !MemoryMonitor class methodsFor:'documentation'!
   771 !MemoryMonitor  class methodsFor:'documentation'!
   755 
   772 
   756 version
   773 version
   757     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.35 1996-04-27 17:59:52 cg Exp $'
   774     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.36 1996-08-24 10:07:24 cg Exp $'
   758 ! !
   775 ! !