MemoryMonitor.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 30 Jan 2013 11:15:09 +0000
branchjv
changeset 12401 4714b9640528
parent 12308 5d9291c0fc27
parent 11947 1616d51b78fe
child 12431 9f0c59c742d5
permissions -rw-r--r--
Merged 235b77901045 and 8332590c5a41 (branch default)

"
 COPYRIGHT (c) 1999 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libtool' }"

ApplicationModel subclass:#MemoryMonitor
	instanceVariableNames:'memoryView'
	classVariableNames:''
	poolDictionaries:''
	category:'Monitors-ST/X'
!

!MemoryMonitor class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1999 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

!

documentation
"
    MemoryMonitor application.

    Shows memory usage (oldspace + newspace). Simple, but useful.

    The numbers shown are:
        tot     total memory usage (i.e. allocated oldSpace + allocated newSpace)
                (does not include the second semispace and other help-areas,
                 such as the remembered set etc.)

        all     current oldSpace in use + newSpace in use

        new     current newSpace in use

        frl     free space in (fragmented) free lists
        fre     compact free area above the used oldSpace

        old     current oldSpace in use

        cod     dynamic compiled code space size (just in time compiler)

        max,    extreme values of 'tot' since the monitor started
        min     (can be reset by typing 'r' in the view)

        t       tenure threshold (1 .. 30)

        I       incremental GC state (2 = idle)

        weak    number of weak objects

        rem     size of rememberedSet

        minsc:  percent of newspace remaining after scavenge (worst case)
                (i.e. the minimum %% of scavenged objects)

        count   number of scavenges since system started

        %       percentage of live objects in newSpace after last scavenge
                (i.e. this is the garbage vs. living objects ratio of
                 newSpace objects after the last scavenge)

    the graphic shows:
        orange  newSpace used
        green   free memory in freeLists
        white   oldSpace used


    the popupMenu offers GC functions; keyboard options are:
        'f' -> faster; 's' -> slower; 'r' -> reset min/max

    [author:]
        Claus Gittinger

    [start with:]
        MemoryMonitor open

    [see also:]
        ObjectMemory MemoryMonitorView
        MemoryUsageMonitor ProcessMonitor
"

! !


!MemoryMonitor class methodsFor:'image specs'!

defaultIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     self defaultIcon inspect
     ImageEditor openOnClass:self andSelector:#defaultIcon
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'MemoryMonitor class defaultIcon'
        ifAbsentPut:[(Depth1Image new) width: 48; height: 48; photometric:(#whiteIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
@@@@@@@@@@@@@@@@@DBA@ P@@DBA@ P@@DBA@ P@@NGC!!08@@UJ%R)T@C?????? @UJ%R)T@@NGC!!08@@DBA@ P@@DBA@ P@@NGC!!08@@UJ%R)T@C?????? 
@UJ%R)T@@NGC!!08@@DBA@ P@@DBA@ P@@NGC!!08@@UJ%R)T@C?????? @UJ%R)T@@NGC!!08@@DBA@ P@@DBA@ P@@NGC!!08@@UJ%R)T@C?????? @UJ%R)T@
@NGC!!08@@DBA@ P@@DBA@ P@@DBA@ P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Y/Y&\"@@_(_)R"@@V(V)R6@@V/V)\\@@P(P)TH@
@P(P)RH@@P/P&RH@@@@@@@@@') ; yourself]
! !


!MemoryMonitor class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:MemoryMonitor andSelector:#windowSpec
     MemoryMonitor new openInterface:#windowSpec
     MemoryMonitor open
    "

    <resource: #canvas>

    ^ 
     #(FullSpec
        name: windowSpec
        window: 
       (WindowSpec
          label: 'MemoryMonitor'
          name: 'MemoryMonitor'
          min: (Point 175 326)
          bounds: (Rectangle 0 0 190 400)
          menu: mainMenu
          icon: defaultIcon
        )
        component: 
       (SpecCollection
          collection: (
           (ArbitraryComponentSpec
              name: 'memoryView'
              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              hasBorder: false
              component: MemoryMonitorView
            )
           )
         
        )
      )
! !


!MemoryMonitor class methodsFor:'menu specs'!

mainMenu
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:NewMemoryMonitor andSelector:#mainMenu
     (Menu new fromLiteralArrayEncoding:(NewMemoryMonitor mainMenu)) startUp
    "

    <resource: #menu>

    ^ 
     #(#Menu
        #(
         #(#MenuItem
            #label: 'File'
            #translateLabel: true
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Exit'
                  #translateLabel: true
                  #value: #closeRequest
                )
               )
              nil
              nil
            )
          )
         #(#MenuItem
            #label: 'GC'
            #translateLabel: true
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Collect Garbage'
                  #translateLabel: true
                  #value: #collectGarbage
                )
               #(#MenuItem
                  #label: 'Collect Garbage && Symbols'
                  #translateLabel: true
                  #value: #collectGarbageAndSymbols
                )
               #(#MenuItem
                  #label: 'Collect Garbage && Compress'
                  #translateLabel: true
                  #value: #collectGarbageAndCompress
                )
               )
              nil
              nil
            )
          )
         #(#MenuItem
            #label: 'Help'
            #translateLabel: true
            #startGroup: #right
            #submenu: 
           #(#Menu
              #(
               #(#MenuItem
                  #label: 'Documentation'
                  #translateLabel: true
                  #value: #openDocumentation
                )
               #(#MenuItem
                  #label: '-'
                )
               #(#MenuItem
                  #label: 'About this Application'
                  #translateLabel: true
                  #value: #openAboutThisApplication
                )
               )
              nil
              nil
            )
          )
         )
        nil
        nil
      )
! !


!MemoryMonitor methodsFor:'actions'!

collectGarbage
     memoryView collectGarbage

    "Modified: / 29-10-2012 / 01:34:24 / cg"
!

collectGarbageAndCompress
     memoryView collectGarbageAndCompress
!

collectGarbageAndSymbols
     memoryView collectGarbageAndSymbols
!

openDocumentation
    HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#MEMORYMONITOR'

! !


!MemoryMonitor methodsFor:'initialization & release'!

postBuildWith:aBuilder
    "This is a hook method generated by the Browser.
     It will be invoked during the initialization of your app/dialog,
     after all of the visual components have been built, 
     but BEFORE the top window is made visible.
     Add any app-specific actions here (reading files, setting up
     values etc.)"

    memoryView := aBuilder componentAt:#memoryView.

    ^ super postBuildWith:aBuilder
! !


!MemoryMonitor class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.70 2012-10-29 00:35:21 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.70 2012-10-29 00:35:21 cg Exp $'
!

version_SVN
    ^ '$Id: MemoryMonitor.st 8074 2012-11-30 17:23:39Z vranyj1 $'
! !