MemoryMonitor.st
changeset 323 f443d7e5bab0
parent 311 c118ce1f8afd
child 350 68c5fed6c9bc
equal deleted inserted replaced
322:e3ccd5e431df 323:f443d7e5bab0
   529      MemoryMonitor open
   529      MemoryMonitor open
   530     "
   530     "
   531 !
   531 !
   532 
   532 
   533 memoryMenu
   533 memoryMenu
   534     |labels selectors|
   534     |m specialMenu labels selectors|
       
   535 
       
   536     labels :=    #(
       
   537                     'scavenge'
       
   538                     'tenure'
       
   539                     'incremental collect'
       
   540                     'reset statistic values'
       
   541                     '-'
       
   542                     'cleanup memory'
       
   543                     '-'
       
   544                     'compress sources'
       
   545                   ).
       
   546     selectors := #(
       
   547                     scavenge
       
   548                     tenure
       
   549                     incrementalCollect
       
   550                     resetStatisticValues
       
   551                     nil
       
   552                     cleanupMemory
       
   553                     nil
       
   554                     compressSources
       
   555                   ).
       
   556 
       
   557     specialMenu := PopUpMenu
       
   558                         labels:(resources array:labels)
       
   559                         selectors:selectors.
   535 
   560 
   536     device ctrlDown ifTrue:[
   561     device ctrlDown ifTrue:[
   537 	labels :=    #(
   562         ^ specialMenu
   538 			'scavenge'
   563     ].
   539 			'tenure'
   564 
   540 			'incremental collect'
   565     labels :=    #(
   541 			'reset statistic values'
   566                     'collect garbage'
   542 			'-'
   567                     'collect garbage & symbols'
   543 			'cleanup memory'
   568                     'collect garbage & compress'
   544 			'-'
   569                     '-'
   545 			'compress sources'
   570                     'background collect'
   546 		      ).
   571                     '-'
   547 	selectors := #(
   572                     'others'
   548 			scavenge
   573                   ).
   549 			tenure
   574 
   550 			incrementalCollect
   575     selectors := #(
   551 			resetStatisticValues
   576                     garbageCollect
   552 			nil
   577                     garbageCollectAndSymbols
   553 			cleanupMemory
   578                     compressingGarbageCollect
   554 			nil
   579                     nil
   555 			compressSources
   580                     backgroundCollect
   556 		      ).
   581                     nil
   557     ] ifFalse:[
   582                     otherMenu
   558 	labels :=    #(
   583                   ).
   559 			'collect garbage'
   584     m := PopUpMenu labels:(resources array:labels)
   560 			'collect garbage & symbols'
   585                    selectors:selectors.
   561 			'collect garbage & compress'
   586 
   562 			'-'
   587     m subMenuAt:#otherMenu put:specialMenu.
   563 			'background collect'
   588     ^ m
   564 		      ).
       
   565 
       
   566 	selectors := #(
       
   567 			garbageCollect
       
   568 			garbageCollectAndSymbols
       
   569 			compressingGarbageCollect
       
   570 			nil
       
   571 			backgroundCollect
       
   572 		      ).
       
   573     ].
       
   574 
       
   575     ^ PopUpMenu labels:(resources array:labels)
       
   576 		 selectors:selectors
       
   577 		receiver:self
       
   578 !
   589 !
   579 
   590 
   580 realize
   591 realize
   581     super realize.
   592     super realize.
   582     updateBlock notNil ifTrue:[
   593     updateBlock notNil ifTrue:[
   630     "
   641     "
   631     ObjectMemory verboseGarbageCollect.
   642     ObjectMemory verboseGarbageCollect.
   632 !
   643 !
   633 
   644 
   634 compressSources
   645 compressSources
   635     Smalltalk compressSources.
   646     (self confirm:'This saves all in-memory source strings into a file
   636     ObjectMemory markAndSweep
   647 and makes methods reference these (file-) strings.
       
   648 
       
   649 If that source file is ever lost or gets out of sync with
       
   650 your system, those method sources are lost and the browser
       
   651 will show garbage. 
       
   652 However, you still have a change file as backup.
       
   653 
       
   654 (Be especially careful, if you move images around:
       
   655  the source file must then be correct one for that image)
       
   656 
       
   657 A compress is only useful, if you added many methods
       
   658 and the systems response time suffers from paging.
       
   659 
       
   660 Compress anyway ?') ifTrue:[
       
   661         Smalltalk compressSources.
       
   662         ObjectMemory markAndSweep
       
   663     ]
       
   664 
       
   665     "Modified: 23.12.1995 / 17:21:57 / cg"
   637 !
   666 !
   638 
   667 
   639 compressingGarbageCollect
   668 compressingGarbageCollect
   640     "perform a blocking compressing garbage collect."
   669     "perform a blocking compressing garbage collect."
   641 
   670 
   656 !
   685 !
   657 
   686 
   658 incrementalCollect
   687 incrementalCollect
   659     "start an incremental GC which does not disturb too much, but is guaranteed to
   688     "start an incremental GC which does not disturb too much, but is guaranteed to
   660      make progress.
   689      make progress.
   661      This is done by doing the igc at a very high priority, but giving up the CPU after
   690      This is done by doing the IGC at a very high priority, but giving up the CPU after
   662      every step. Due to the amount of context switches, this may take a while to finish."
   691      every step. Due to the long delays, this may take a while to finish.
   663  
   692      Notice, that this is different from doing a background collect: that one
       
   693      may not make any progress if higher prio processes are runnable."
       
   694 
       
   695     |done delay|
       
   696 
   664     [
   697     [
   665 	[ObjectMemory gcStep] whileFalse:[(Delay forMilliseconds:1) wait]
   698         done := false.
       
   699         delay := Delay new.
       
   700         [done] whileFalse:[
       
   701             10 timesRepeat:[
       
   702                 done ifFalse:[done := ObjectMemory gcStep].
       
   703             ].
       
   704             (delay delay:10) wait
       
   705         ]
   666     ] forkAt:Processor highestPriority
   706     ] forkAt:Processor highestPriority
       
   707 
       
   708     "Modified: 23.12.1995 / 17:31:55 / cg"
   667 !
   709 !
   668 
   710 
   669 resetStatisticValues 
   711 resetStatisticValues 
   670     ObjectMemory resetMaxInterruptLatency.
   712     ObjectMemory resetMaxInterruptLatency.
   671     ObjectMemory resetMinScavengeReclamation.
   713     ObjectMemory resetMinScavengeReclamation.
   689 ! !
   731 ! !
   690 
   732 
   691 !MemoryMonitor class methodsFor:'documentation'!
   733 !MemoryMonitor class methodsFor:'documentation'!
   692 
   734 
   693 version
   735 version
   694     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.29 1995-12-18 14:23:08 cg Exp $'
   736     ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.30 1995-12-23 17:43:25 cg Exp $'
   695 ! !
   737 ! !