MemoryMonitorView.st
branchjv
changeset 12435 1f1faf35be04
parent 12431 9f0c59c742d5
parent 12408 c54a692c5e1f
child 12807 ba8c5416aa28
equal deleted inserted replaced
12434:bc21844a6b32 12435:1f1faf35be04
    12 "{ Package: 'stx:libtool' }"
    12 "{ Package: 'stx:libtool' }"
    13 
    13 
    14 View subclass:#MemoryMonitorView
    14 View subclass:#MemoryMonitorView
    15 	instanceVariableNames:'updateInterval updateBlock myProcess oldData newData freeData
    15 	instanceVariableNames:'updateInterval updateBlock myProcess oldData newData freeData
    16 		updateIndex org maxTotal minTotal dX newColor freeColor oldColor
    16 		updateIndex org maxTotal minTotal dX newColor freeColor oldColor
    17 		prevTotal prevFree prevFree2 prevOld scale drawLock prevMemUsed
    17 		prevTotal prevLimit prevFree prevFree2 prevOld scale drawLock
    18 		prevCodeUsed prevNumWeak prevNumRem prevNumLifoRem prevTenureAge
    18 		prevMemUsed prevCodeUsed prevNumWeak prevNumRem prevNumLifoRem
    19 		prevIGCPhase prevLastScavengeReclamation
    19 		prevTenureAge prevIGCPhase prevLastScavengeReclamation
    20 		prevMinScavengeReclamation prevScavengeCount mallocColor'
    20 		prevMinScavengeReclamation prevScavengeCount mallocColor'
    21 	classVariableNames:''
    21 	classVariableNames:''
    22 	poolDictionaries:''
    22 	poolDictionaries:''
    23 	category:'Monitors-ST/X'
    23 	category:'Monitors-ST/X'
    24 !
    24 !
   104         ObjectMemory MemoryMonitor
   104         ObjectMemory MemoryMonitor
   105         MemoryUsageMonitor ProcessMonitor
   105         MemoryUsageMonitor ProcessMonitor
   106 "
   106 "
   107 ! !
   107 ! !
   108 
   108 
       
   109 
   109 !MemoryMonitorView methodsFor:'drawing'!
   110 !MemoryMonitorView methodsFor:'drawing'!
   110 
   111 
   111 displayKilo:aNumber name:nm y:y
   112 displayKilo:aNumber name:nm y:y
   112     |s|
   113     |s|
   113 
   114 
   114     aNumber >= (1024*1024*99) ifTrue:[
   115     aNumber >= (1024*1024*1024*2) ifTrue:[
   115         s := nm , ((aNumber // (1024*1024)) printStringLeftPaddedTo:5) , 'M '.
   116         s := nm , ((aNumber // (1024*1024*1024)) printStringLeftPaddedTo:5) , 'G '.
   116     ] ifFalse:[
   117     ] ifFalse:[
   117         s := nm , ((aNumber // 1024) printStringLeftPaddedTo:5) , 'k '.
   118         aNumber >= (1024*1024*16) ifTrue:[
       
   119             s := nm , ((aNumber // (1024*1024)) printStringLeftPaddedTo:5) , 'M '.
       
   120         ] ifFalse:[
       
   121             s := nm , ((aNumber // 1024) printStringLeftPaddedTo:5) , 'k '.
       
   122         ].
   118     ].
   123     ].
   119     self displayOpaqueString:s x:0 y:y.
   124     self displayOpaqueString:s x:0 y:y.
   120 
   125 
   121     "Modified: / 23.9.1998 / 13:19:04 / cg"
   126     "Modified: / 23.9.1998 / 13:19:04 / cg"
   122 !
   127 !
   175     ].
   180     ].
   176 
   181 
   177     x < org ifTrue:[
   182     x < org ifTrue:[
   178         "/ force redraw.
   183         "/ force redraw.
   179 
   184 
   180         prevFree := prevFree2 := prevOld := prevTotal := nil.
   185         prevFree := prevFree2 := prevOld := prevTotal := prevLimit := nil.
   181         prevMemUsed := prevCodeUsed := prevNumWeak := prevNumRem := nil.
   186         prevMemUsed := prevCodeUsed := prevNumWeak := prevNumRem := nil.
   182         prevNumLifoRem := prevTenureAge := prevIGCPhase := nil.
   187         prevNumLifoRem := prevTenureAge := prevIGCPhase := nil.
   183         prevLastScavengeReclamation := prevMinScavengeReclamation := nil.
   188         prevLastScavengeReclamation := prevMinScavengeReclamation := nil.
   184         prevScavengeCount := nil.
   189         prevScavengeCount := nil.
   185 
   190 
   330 
   335 
   331     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2
   336     |oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2
   332      mallocAllocated mallocTotal
   337      mallocAllocated mallocTotal
   333      codeUsed numWeak numRem numLifoRem tenureAge igcPhase 
   338      codeUsed numWeak numRem numLifoRem tenureAge igcPhase 
   334      minScavengeReclamation lastScavengeReclamation scavengeCount
   339      minScavengeReclamation lastScavengeReclamation scavengeCount
   335      y half s fontHeight fontDescent total n prevMallocAllocated prevMallocTotal|
   340      y half s fontHeight fontAscent fontDescent 
       
   341      limit total n prevMallocAllocated prevMallocTotal|
   336 
   342 
   337     oldMemUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
   343     oldMemUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
   338     newMemUsed := ObjectMemory newSpaceUsed.
   344     newMemUsed := ObjectMemory newSpaceUsed.
   339     freeMem := ObjectMemory freeListSpace.
   345     freeMem := ObjectMemory freeListSpace.
   340     oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize.
   346     oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize.
   341     newSpaceSize := ObjectMemory newSpaceSize.
   347     newSpaceSize := ObjectMemory newSpaceSize.
   342 
   348 
   343     mallocAllocated := ObjectMemory mallocAllocated.
   349     mallocAllocated := ObjectMemory mallocAllocated.
   344     mallocTotal := ObjectMemory mallocTotal.
   350     mallocTotal := ObjectMemory mallocTotal.
       
   351     limit := ObjectMemory maxOldSpace.
   345 
   352 
   346     memUsed := oldMemUsed + newMemUsed "- freeMem".
   353     memUsed := oldMemUsed + newMemUsed "- freeMem".
   347     total := oldSpaceSize + newSpaceSize.
   354     total := oldSpaceSize + newSpaceSize.
   348     free2 := ObjectMemory freeSpace.
   355     free2 := ObjectMemory freeSpace.
   349 
   356 
   350     self paint:White on:Black.
   357     self paint:White on:Black.
   351 
   358 
   352     fontDescent := font descent.
   359     fontDescent := font descent.
       
   360     fontAscent := font ascent.
   353     fontHeight := font height + fontDescent.
   361     fontHeight := font height + fontDescent.
   354     half := height // 2 + fontDescent.
   362     half := height // 2 + fontDescent.
   355 
   363 
   356     y := half - (fontHeight * 8).
   364     y := half - (fontHeight * 8).
   357 
   365 
       
   366     limit ~~ prevLimit ifTrue:[
       
   367         self displayKilo:limit    name:'lim ' y:fontAscent.
       
   368         prevLimit := limit.
       
   369     ].
   358     total ~~ prevTotal ifTrue:[
   370     total ~~ prevTotal ifTrue:[
   359         ((total - freeMem) < minTotal) ifTrue:[
   371         ((total - freeMem) < minTotal) ifTrue:[
   360             minTotal := total - freeMem.
   372             minTotal := total - freeMem.
   361         ].
   373         ].
   362         (total > maxTotal) ifTrue:[
   374         (total > maxTotal) ifTrue:[
   363             maxTotal := total.
   375             maxTotal := total.
   364         ].
   376         ].
   365 
   377 
   366         self displayKilo:maxTotal name:'max ' y:font ascent.
   378         self displayKilo:maxTotal name:'max ' y:fontAscent + fontHeight.
   367         self displayKilo:minTotal name:'min ' y:(height - font descent).
   379         self displayKilo:minTotal name:'min ' y:(height - fontDescent).
   368         self displayKilo:total    name:'tot ' y:y.
   380         self displayKilo:total    name:'tot ' y:y.
   369 
   381 
   370         prevTotal := total.
   382         prevTotal := total.
   371     ].
   383     ].
   372 
   384 
   512     ].
   524     ].
   513 
   525 
   514     "Created: / 7.11.1995 / 14:48:16 / cg"
   526     "Created: / 7.11.1995 / 14:48:16 / cg"
   515     "Modified: / 14.7.1998 / 23:35:53 / cg"
   527     "Modified: / 14.7.1998 / 23:35:53 / cg"
   516 ! !
   528 ! !
       
   529 
   517 
   530 
   518 !MemoryMonitorView methodsFor:'events'!
   531 !MemoryMonitorView methodsFor:'events'!
   519 
   532 
   520 keyPress:key x:x y:y
   533 keyPress:key x:x y:y
   521     key == $f ifTrue:[
   534     key == $f ifTrue:[
   577     self clear.
   590     self clear.
   578     self redraw.
   591     self redraw.
   579 
   592 
   580     "Modified: / 7.9.1998 / 21:41:13 / cg"
   593     "Modified: / 7.9.1998 / 21:41:13 / cg"
   581 ! !
   594 ! !
       
   595 
   582 
   596 
   583 !MemoryMonitorView methodsFor:'initialization & release'!
   597 !MemoryMonitorView methodsFor:'initialization & release'!
   584 
   598 
   585 destroy
   599 destroy
   586     updateBlock notNil ifTrue:[
   600     updateBlock notNil ifTrue:[
   674 reinitStyle
   688 reinitStyle
   675     "ignore style changes"
   689     "ignore style changes"
   676 
   690 
   677     "Created: / 15.9.1998 / 15:22:46 / cg"
   691     "Created: / 15.9.1998 / 15:22:46 / cg"
   678 ! !
   692 ! !
       
   693 
   679 
   694 
   680 !MemoryMonitorView methodsFor:'menu functions'!
   695 !MemoryMonitorView methodsFor:'menu functions'!
   681 
   696 
   682 backgroundCollect
   697 backgroundCollect
   683     "start a background (non disturbing) incremental GC. 
   698     "start a background (non disturbing) incremental GC. 
  1004 
  1019 
  1005     "Created: 27.6.1997 / 14:21:45 / cg"
  1020     "Created: 27.6.1997 / 14:21:45 / cg"
  1006     "Modified: 27.6.1997 / 14:22:47 / cg"
  1021     "Modified: 27.6.1997 / 14:22:47 / cg"
  1007 ! !
  1022 ! !
  1008 
  1023 
       
  1024 
  1009 !MemoryMonitorView methodsFor:'private'!
  1025 !MemoryMonitorView methodsFor:'private'!
  1010 
  1026 
  1011 updateProcess
  1027 updateProcess
  1012     [true] whileTrue:[
  1028     [true] whileTrue:[
  1013         Delay waitForSeconds:updateInterval.
  1029         Delay waitForSeconds:updateInterval.
  1015     ]
  1031     ]
  1016 
  1032 
  1017     "Modified: / 23.9.1998 / 12:40:31 / cg"
  1033     "Modified: / 23.9.1998 / 12:40:31 / cg"
  1018 ! !
  1034 ! !
  1019 
  1035 
       
  1036 
  1020 !MemoryMonitorView class methodsFor:'documentation'!
  1037 !MemoryMonitorView class methodsFor:'documentation'!
  1021 
  1038 
  1022 version
  1039 version
  1023     ^ '$Id: MemoryMonitorView.st 7854 2012-01-30 17:49:41Z vranyj1 $'
  1040     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitorView.st,v 1.18 2013-02-20 09:53:50 cg Exp $'
  1024 !
  1041 !
  1025 
  1042 
  1026 version_CVS
  1043 version_CVS
  1027     ^ '§Header: /cvs/stx/stx/libtool/MemoryMonitorView.st,v 1.16 2011/08/16 13:13:38 stefan Exp §'
  1044     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitorView.st,v 1.18 2013-02-20 09:53:50 cg Exp $'
  1028 !
  1045 !
  1029 
  1046 
  1030 version_HG
  1047 version_HG
  1031 
  1048 
  1032     ^ '$Changeset: <not expanded> $'
  1049     ^ '$Changeset: <not expanded> $'