45
|
1 |
"
|
49
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
45
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
19
|
12 |
|
85
|
13 |
'From Smalltalk/X, Version:2.10.5 on 22-mar-1995 at 7:43:35 am'!
|
|
14 |
|
19
|
15 |
StandardSystemView subclass:#MemoryMonitor
|
85
|
16 |
instanceVariableNames:'updateInterval updateBlock myProcess oldData newData freeData
|
93
|
17 |
updateIndex org maxTotal minTotal dX newColor freeColor oldColor
|
|
18 |
prevTotal prevFree prevFree2 prevOld scale'
|
45
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Tools'
|
19
|
22 |
!
|
|
23 |
|
49
|
24 |
!MemoryMonitor class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
!
|
|
39 |
|
|
40 |
version
|
|
41 |
"
|
156
|
42 |
$Header: /cvs/stx/stx/libtool/Attic/MemMonitor.st,v 1.22 1995-11-07 17:21:30 cg Exp $
|
49
|
43 |
"
|
|
44 |
!
|
|
45 |
|
|
46 |
documentation
|
|
47 |
"
|
|
48 |
Shows memory usage (oldspace + newspace). Simple, but useful.
|
|
49 |
|
|
50 |
The numbers shown are:
|
|
51 |
tot total memory usage (i.e. allocated oldSpace + allocated newSpace)
|
|
52 |
(does not include the second semispace and other help-areas,
|
|
53 |
such as the remembered set etc.)
|
|
54 |
|
|
55 |
all current oldSpace in use + newSpace in use
|
|
56 |
|
|
57 |
new current newSpace in use
|
|
58 |
|
52
|
59 |
frl free space in (fragmented) free lists
|
|
60 |
fre compact free area above the used oldSpace
|
49
|
61 |
|
|
62 |
old current oldSpace in use
|
|
63 |
|
52
|
64 |
max, extreme values of 'tot' since the monitor started
|
|
65 |
min (can be reset by typing 'r' in the view)
|
49
|
66 |
|
|
67 |
t tenure threshold
|
|
68 |
|
|
69 |
I incremental GC state
|
|
70 |
|
109
|
71 |
weak number of weak objects
|
|
72 |
|
108
|
73 |
rem size of rememberedSet
|
|
74 |
|
|
75 |
minsc: percent of newspace remaining after scavenge (worst case)
|
|
76 |
(i.e. the minimum %% of scavenged objects)
|
|
77 |
|
|
78 |
count number of scavenges since system started
|
|
79 |
|
52
|
80 |
% percentage of live objects in newSpace after last scavenge
|
|
81 |
(i.e. this is the garbage vs. living objects ratio of
|
|
82 |
newSpace objects after the last scavenge)
|
|
83 |
|
49
|
84 |
the graphic shows:
|
|
85 |
yellow newSpace used
|
|
86 |
green free memory in freeLists
|
|
87 |
white oldSpace used
|
52
|
88 |
|
|
89 |
|
|
90 |
the popupMenu offers GC functions; keyboard options are:
|
|
91 |
'f' -> faster; 's' -> slower; 'r' -> reset min/max
|
49
|
92 |
"
|
|
93 |
! !
|
|
94 |
|
|
95 |
!MemoryMonitor class methodsFor:'defaults'!
|
|
96 |
|
|
97 |
defaultExtent
|
109
|
98 |
^ (200 @ 280)
|
52
|
99 |
!
|
19
|
100 |
|
52
|
101 |
defaultLabel
|
|
102 |
^ 'Memory Monitor'
|
|
103 |
!
|
19
|
104 |
|
52
|
105 |
defaultIcon
|
|
106 |
|i|
|
19
|
107 |
|
93
|
108 |
i := Image fromFile:'MemMonitor.xbm'.
|
52
|
109 |
i notNil ifTrue:[^ i].
|
|
110 |
^ super defaultIcon
|
19
|
111 |
! !
|
|
112 |
|
|
113 |
!MemoryMonitor methodsFor:'drawing'!
|
|
114 |
|
85
|
115 |
updateDisplay
|
|
116 |
"update picture; trigger next update"
|
|
117 |
|
109
|
118 |
|total oldSpaceUsed newSpaceUsed freeMem oldSpaceSize
|
85
|
119 |
gWidth shift scaleChange margin mustWait|
|
|
120 |
|
|
121 |
shown ifTrue:[
|
91
|
122 |
oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
|
85
|
123 |
newSpaceUsed := ObjectMemory newSpaceUsed.
|
109
|
124 |
freeMem := ObjectMemory freeListSpace + (ObjectMemory oldSpaceSize - ObjectMemory oldSpaceUsed).
|
|
125 |
oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize.
|
|
126 |
total := oldSpaceSize + ObjectMemory newSpaceSize.
|
85
|
127 |
|
|
128 |
scaleChange := false.
|
|
129 |
|
|
130 |
((total - freeMem) < minTotal) ifTrue:[
|
|
131 |
minTotal := total - freeMem.
|
|
132 |
scaleChange := true
|
|
133 |
].
|
|
134 |
(total > maxTotal) ifTrue:[
|
|
135 |
maxTotal := total.
|
|
136 |
scaleChange := true
|
|
137 |
].
|
|
138 |
|
109
|
139 |
oldData at:updateIndex put:oldSpaceSize. "/ oldSpaceUsed.
|
85
|
140 |
newData at:updateIndex put:newSpaceUsed.
|
|
141 |
freeData at:updateIndex put:freeMem.
|
|
142 |
updateIndex := updateIndex + 1.
|
|
143 |
|
|
144 |
scaleChange ifTrue:[
|
|
145 |
scale := height asFloat / (maxTotal + 100000).
|
|
146 |
self redraw
|
|
147 |
].
|
|
148 |
|
|
149 |
gWidth := width - org.
|
|
150 |
margin := 1.
|
49
|
151 |
|
85
|
152 |
mustWait := false.
|
|
153 |
((updateIndex-1) >= (gWidth - margin)) ifTrue:[
|
|
154 |
"on slow displays, use:"
|
|
155 |
"/ shift := gWidth // 4.
|
|
156 |
|
|
157 |
"for smooth display, use:"
|
|
158 |
shift := 1.
|
|
159 |
|
|
160 |
oldData replaceFrom:1 with:oldData startingAt:shift+1.
|
|
161 |
newData replaceFrom:1 with:newData startingAt:shift+1.
|
|
162 |
freeData replaceFrom:1 with:freeData startingAt:shift+1.
|
|
163 |
|
|
164 |
updateIndex := updateIndex - shift.
|
|
165 |
dX := dX + shift.
|
|
166 |
|
|
167 |
self catchExpose.
|
|
168 |
self copyFrom:self
|
|
169 |
x:(org + shift) y:0
|
|
170 |
toX:org y:0
|
|
171 |
width:(gWidth - shift - margin)
|
|
172 |
height:height.
|
|
173 |
self clearRectangleX:(width - margin - shift) y:0
|
|
174 |
width:shift height:height.
|
|
175 |
mustWait := true.
|
|
176 |
].
|
|
177 |
|
|
178 |
self updateLineX:(updateIndex - 1 + org - 1)
|
|
179 |
total:total
|
109
|
180 |
old:oldSpaceSize "/ oldSpaceUsed
|
85
|
181 |
new:newSpaceUsed
|
|
182 |
free:freeMem.
|
|
183 |
|
|
184 |
self updateNumbers.
|
|
185 |
mustWait ifTrue:[
|
|
186 |
self waitForExpose.
|
|
187 |
]
|
|
188 |
|
|
189 |
].
|
|
190 |
|
|
191 |
updateBlock notNil ifTrue:[
|
|
192 |
Processor addTimedBlock:updateBlock afterSeconds:updateInterval
|
|
193 |
].
|
49
|
194 |
!
|
|
195 |
|
|
196 |
redrawX:x y:y width:w height:h
|
|
197 |
"redraw data"
|
|
198 |
|
107
|
199 |
|total oldSpaceUsed newSpaceUsed freeMem lx startIdx endIdx
|
52
|
200 |
right|
|
49
|
201 |
|
|
202 |
shown ifFalse:[^ self].
|
|
203 |
|
52
|
204 |
right := x + w - 1.
|
|
205 |
right >= org ifTrue:[
|
49
|
206 |
lx := x.
|
|
207 |
lx < org ifTrue:[
|
|
208 |
lx := org
|
|
209 |
].
|
|
210 |
|
91
|
211 |
total := ObjectMemory symSpaceSize
|
57
|
212 |
+ ObjectMemory oldSpaceSize
|
|
213 |
+ ObjectMemory newSpaceSize.
|
49
|
214 |
|
52
|
215 |
startIdx := (lx-org+1).
|
49
|
216 |
startIdx < 1 ifTrue:[
|
|
217 |
startIdx := 1
|
|
218 |
].
|
|
219 |
|
52
|
220 |
endIdx := right-org+1.
|
49
|
221 |
endIdx >= updateIndex ifTrue:[
|
|
222 |
endIdx := updateIndex-1.
|
|
223 |
].
|
|
224 |
dX := 0.
|
|
225 |
|
|
226 |
startIdx to:endIdx do:[:i |
|
|
227 |
newSpaceUsed := newData at:i.
|
|
228 |
newSpaceUsed notNil ifTrue:[
|
|
229 |
oldSpaceUsed := oldData at:i.
|
|
230 |
freeMem := freeData at:i.
|
|
231 |
|
|
232 |
self updateLineX:lx - dX
|
|
233 |
total:total
|
|
234 |
old:oldSpaceUsed
|
|
235 |
new:newSpaceUsed
|
52
|
236 |
free:freeMem.
|
49
|
237 |
].
|
|
238 |
lx := lx + 1
|
|
239 |
]
|
|
240 |
].
|
|
241 |
|
|
242 |
x < org ifTrue:[
|
|
243 |
prevFree := prevFree2 := prevOld := prevTotal := nil.
|
|
244 |
|
|
245 |
self updateNumbers.
|
|
246 |
]
|
|
247 |
!
|
|
248 |
|
109
|
249 |
updateLineX:x total:total old:oldSpaceSize new:newSpaceUsed free:freeMem
|
|
250 |
|hNew hOld hFree y1 y2 y3|
|
49
|
251 |
|
|
252 |
hNew := (newSpaceUsed * scale) asInteger.
|
109
|
253 |
hOld := (oldSpaceSize * scale) // 2.
|
|
254 |
hFree := (freeMem * scale) // 2.
|
49
|
255 |
|
|
256 |
y1 := height - 1.
|
109
|
257 |
|
49
|
258 |
y2 := y1 - hOld.
|
|
259 |
self paint:oldColor.
|
|
260 |
self displayLineFromX:x y:y1 toX:x y:y2.
|
|
261 |
|
109
|
262 |
y3 := y1 - hFree.
|
49
|
263 |
self paint:freeColor.
|
109
|
264 |
self displayLineFromX:x y:y1 toX:x y:y3.
|
49
|
265 |
|
109
|
266 |
y1 := y2 - hNew.
|
49
|
267 |
self paint:newColor.
|
|
268 |
self displayLineFromX:x y:y1 toX:x y:y2.
|
|
269 |
!
|
|
270 |
|
|
271 |
updateNumbers
|
|
272 |
"redraw numbers.
|
|
273 |
The values shown are:
|
|
274 |
max: maximum memory used since monitor started
|
|
275 |
min: minimum memory used since monitor started
|
|
276 |
tot: total memory used (overall oldSpace + overall newSpace)
|
|
277 |
all: current memory in use (oldSpace + newSpace)
|
|
278 |
new: current newSpace in use
|
|
279 |
free: current size of freelist in oldSpace
|
|
280 |
old: current oldSpace in use
|
156
|
281 |
t: current tenure age
|
|
282 |
I: IGC state
|
|
283 |
weak: number of weak arrays in the system
|
108
|
284 |
rem remembered set size
|
109
|
285 |
lrem lifo remembered set size
|
156
|
286 |
minsc: percent of newspace remaining after scavenge (worst case)
|
|
287 |
irq: max. interrupt delay
|
|
288 |
count of scavenges / last scavenge survivor rate
|
|
289 |
|
49
|
290 |
"
|
|
291 |
|
|
292 |
|oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2
|
107
|
293 |
y half s fontHeight total n|
|
49
|
294 |
|
91
|
295 |
oldMemUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed.
|
49
|
296 |
newMemUsed := ObjectMemory newSpaceUsed.
|
|
297 |
freeMem := ObjectMemory freeListSpace.
|
91
|
298 |
oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize.
|
49
|
299 |
newSpaceSize := ObjectMemory newSpaceSize.
|
|
300 |
|
|
301 |
memUsed := oldMemUsed + newMemUsed "- freeMem".
|
|
302 |
total := oldSpaceSize + newSpaceSize.
|
68
|
303 |
free2 := ObjectMemory freeSpace.
|
49
|
304 |
|
|
305 |
self paint:White on:Black.
|
|
306 |
|
|
307 |
fontHeight := font height + font descent.
|
|
308 |
half := height // 2 + font descent.
|
|
309 |
|
109
|
310 |
y := half - (fontHeight * 5).
|
49
|
311 |
|
|
312 |
total ~~ prevTotal ifTrue:[
|
52
|
313 |
((total - freeMem) < minTotal) ifTrue:[
|
|
314 |
minTotal := total - freeMem.
|
|
315 |
].
|
|
316 |
(total > maxTotal) ifTrue:[
|
|
317 |
maxTotal := total.
|
|
318 |
].
|
|
319 |
|
60
|
320 |
s := 'max ' , ((maxTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
|
52
|
321 |
self displayOpaqueString:s x:0 y:font ascent.
|
|
322 |
|
60
|
323 |
s := 'min ' , ((minTotal // 1024) printStringLeftPaddedTo:5) , 'k '.
|
52
|
324 |
self displayOpaqueString:s x:0 y:(height - font descent).
|
|
325 |
|
60
|
326 |
s := 'tot ' , ((total // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
327 |
self displayOpaqueString:s x:0 y:y.
|
52
|
328 |
|
49
|
329 |
prevTotal := total.
|
|
330 |
].
|
|
331 |
|
|
332 |
y := y + fontHeight.
|
60
|
333 |
s := 'all ' , ((memUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
334 |
self displayOpaqueString:s x:0 y:y.
|
|
335 |
|
|
336 |
y := y + fontHeight.
|
|
337 |
self paint:newColor.
|
60
|
338 |
s := 'new ' , ((newMemUsed // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
339 |
self displayOpaqueString:s x:0 y:y.
|
|
340 |
|
|
341 |
y := y + fontHeight.
|
|
342 |
freeMem ~~ prevFree ifTrue:[
|
|
343 |
self paint:freeColor.
|
60
|
344 |
s := 'frl ' , ((freeMem // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
345 |
self displayOpaqueString:s x:0 y:y.
|
|
346 |
prevFree := freeMem.
|
|
347 |
].
|
|
348 |
|
|
349 |
y := y + fontHeight.
|
|
350 |
free2 ~~ prevFree2 ifTrue:[
|
|
351 |
self paint:freeColor.
|
60
|
352 |
s := 'fre ' , ((free2 // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
353 |
self displayOpaqueString:s x:0 y:y.
|
|
354 |
prevFree2 := free2.
|
|
355 |
].
|
|
356 |
|
|
357 |
y := y + fontHeight.
|
|
358 |
(oldMemUsed - freeMem) ~~ prevOld ifTrue:[
|
|
359 |
self paint:oldColor.
|
60
|
360 |
s := 'old ' , (((oldMemUsed - freeMem) // 1024) printStringLeftPaddedTo:5) , 'k '.
|
49
|
361 |
self displayOpaqueString:s x:0 y:y.
|
|
362 |
prevOld := (oldMemUsed - freeMem).
|
|
363 |
].
|
|
364 |
|
|
365 |
"
|
|
366 |
the following is internal - normally only interresting when debugging the VM
|
|
367 |
"
|
|
368 |
y := y + fontHeight.
|
|
369 |
self paint:oldColor.
|
60
|
370 |
s := 't:' , (ObjectMemory tenureAge printStringLeftPaddedTo:2) , ' '.
|
108
|
371 |
s := s , ' I:' , (ObjectMemory incrementalGCPhase printStringLeftPaddedTo:2) , ' '.
|
|
372 |
self displayOpaqueString:s x:0 y:y.
|
|
373 |
|
|
374 |
y := y + fontHeight.
|
109
|
375 |
s := 'weak: ' , (ObjectMemory numberOfWeakObjects printStringLeftPaddedTo:4).
|
|
376 |
self displayOpaqueString:s x:0 y:y.
|
|
377 |
|
|
378 |
y := y + fontHeight.
|
108
|
379 |
s := 'rem: ' , (ObjectMemory rememberedSetSize printStringLeftPaddedTo:5).
|
49
|
380 |
self displayOpaqueString:s x:0 y:y.
|
|
381 |
|
109
|
382 |
y := y + fontHeight.
|
|
383 |
s := 'lrem: ' , (ObjectMemory lifoRememberedSetSize printStringLeftPaddedTo:4 ifLarger:['****']).
|
|
384 |
self displayOpaqueString:s x:0 y:y.
|
|
385 |
|
49
|
386 |
"/ does no longer make sense to show ....
|
|
387 |
"/ y := y + fontHeight.
|
|
388 |
"/ ObjectMemory runsSingleOldSpace ifTrue:[
|
|
389 |
"/ self displayOpaqueString:'single' x:0 y:(half + (fontHeight*4)).
|
|
390 |
"/ ].
|
|
391 |
|
52
|
392 |
y := y + fontHeight.
|
108
|
393 |
n := ObjectMemory minScavengeReclamation / ObjectMemory newSpaceSize * 100.0.
|
52
|
394 |
n := 100 - n asInteger.
|
108
|
395 |
s := 'minSc ', (n printStringLeftPaddedTo:3) , '%'.
|
|
396 |
self displayOpaqueString:s x:0 y:y.
|
|
397 |
|
|
398 |
y := y + fontHeight.
|
156
|
399 |
n := ObjectMemory maxInterruptDelay.
|
|
400 |
n notNil ifTrue:[
|
|
401 |
s := 'irq ', (n printStringLeftPaddedTo:3) , ' ms'.
|
|
402 |
] ifFalse:[
|
|
403 |
s := 'irq ---'
|
|
404 |
].
|
|
405 |
self displayOpaqueString:s x:0 y:y.
|
|
406 |
|
|
407 |
y := y + fontHeight.
|
108
|
408 |
n := ObjectMemory lastScavengeReclamation / ObjectMemory newSpaceSize * 100.0.
|
|
409 |
n := 100 - n asInteger.
|
|
410 |
s := (ObjectMemory scavengeCount printStringLeftPaddedTo:6)
|
75
|
411 |
, (n printStringLeftPaddedTo:3) , '%'.
|
52
|
412 |
self displayOpaqueString:s x:0 y:y.
|
156
|
413 |
|
|
414 |
"Created: 7.11.1995 / 14:48:16 / cg"
|
49
|
415 |
!
|
|
416 |
|
85
|
417 |
redraw
|
|
418 |
"redraw all"
|
45
|
419 |
|
85
|
420 |
self clear.
|
|
421 |
self redrawX:0 y:0 width:width height:height
|
45
|
422 |
! !
|
|
423 |
|
|
424 |
!MemoryMonitor methodsFor:'destroying'!
|
|
425 |
|
|
426 |
destroy
|
|
427 |
updateBlock notNil ifTrue:[
|
|
428 |
Processor removeTimedBlock:updateBlock.
|
|
429 |
] ifFalse:[
|
|
430 |
myProcess terminate.
|
|
431 |
myProcess := nil
|
19
|
432 |
].
|
49
|
433 |
oldData := newData := freeData := nil.
|
45
|
434 |
super destroy
|
19
|
435 |
! !
|
|
436 |
|
|
437 |
!MemoryMonitor methodsFor:'events'!
|
|
438 |
|
49
|
439 |
sizeChanged:how
|
|
440 |
|nn no nf delta oldSize newSize|
|
|
441 |
|
|
442 |
super sizeChanged:how.
|
19
|
443 |
|
45
|
444 |
oldSize := oldData size.
|
49
|
445 |
newSize := width-org+1.
|
|
446 |
|
|
447 |
(newSize == oldSize) ifTrue:[^ self].
|
45
|
448 |
|
49
|
449 |
nn := Array new:newSize.
|
|
450 |
no := Array new:newSize.
|
|
451 |
nf := Array new:newSize.
|
45
|
452 |
|
49
|
453 |
(newSize > oldSize) ifTrue:[
|
45
|
454 |
nn replaceFrom:1 to:oldSize with:newData.
|
|
455 |
no replaceFrom:1 to:oldSize with:oldData.
|
|
456 |
nf replaceFrom:1 to:oldSize with:freeData
|
19
|
457 |
] ifFalse:[
|
49
|
458 |
delta := (oldSize - newSize).
|
|
459 |
nn replaceFrom:1 with:newData startingAt:delta+1.
|
|
460 |
no replaceFrom:1 with:oldData startingAt:delta+1.
|
|
461 |
nf replaceFrom:1 with:freeData startingAt:delta+1.
|
|
462 |
updateIndex > newSize ifTrue:[
|
|
463 |
updateIndex := updateIndex - delta.
|
45
|
464 |
]
|
19
|
465 |
].
|
|
466 |
newData := nn.
|
45
|
467 |
oldData := no.
|
49
|
468 |
freeData := nf.
|
|
469 |
|
52
|
470 |
scale := height asFloat / (maxTotal + 100000).
|
|
471 |
self clear.
|
49
|
472 |
self redraw
|
85
|
473 |
!
|
|
474 |
|
|
475 |
keyPress:key x:x y:y
|
|
476 |
key == $f ifTrue:[
|
|
477 |
"faster"
|
|
478 |
updateInterval := updateInterval / 2
|
|
479 |
].
|
|
480 |
key == $s ifTrue:[
|
|
481 |
"slower"
|
|
482 |
updateInterval := updateInterval * 2
|
|
483 |
].
|
|
484 |
key == $r ifTrue:[
|
|
485 |
"reset max"
|
|
486 |
maxTotal := prevTotal.
|
|
487 |
scale := height asFloat / (maxTotal + 100000).
|
156
|
488 |
self resetStatisticValues.
|
85
|
489 |
self redraw.
|
|
490 |
]
|
156
|
491 |
|
|
492 |
"Modified: 7.11.1995 / 17:45:13 / cg"
|
19
|
493 |
! !
|
45
|
494 |
|
|
495 |
!MemoryMonitor methodsFor:'initialization'!
|
|
496 |
|
85
|
497 |
memoryMenu
|
|
498 |
|labels selectors|
|
|
499 |
|
105
|
500 |
device ctrlDown ifTrue:[
|
|
501 |
labels := #(
|
|
502 |
'scavenge'
|
|
503 |
'tenure'
|
109
|
504 |
'incremental collect'
|
156
|
505 |
'reset statistic values'
|
105
|
506 |
'-'
|
|
507 |
'cleanup memory'
|
107
|
508 |
'-'
|
|
509 |
'compress sources'
|
105
|
510 |
).
|
|
511 |
selectors := #(
|
|
512 |
scavenge
|
|
513 |
tenure
|
109
|
514 |
incrementalCollect
|
156
|
515 |
resetStatisticValues
|
105
|
516 |
nil
|
|
517 |
cleanupMemory
|
107
|
518 |
nil
|
|
519 |
compressSources
|
105
|
520 |
).
|
|
521 |
] ifFalse:[
|
|
522 |
labels := #(
|
|
523 |
'collect garbage'
|
|
524 |
'collect garbage & symbols'
|
|
525 |
'collect garbage & compress'
|
|
526 |
'-'
|
|
527 |
'background collect'
|
|
528 |
).
|
85
|
529 |
|
105
|
530 |
selectors := #(
|
|
531 |
garbageCollect
|
|
532 |
garbageCollectAndSymbols
|
|
533 |
compressingGarbageCollect
|
|
534 |
nil
|
|
535 |
backgroundCollect
|
|
536 |
).
|
|
537 |
].
|
85
|
538 |
|
|
539 |
^ PopUpMenu labels:(resources array:labels)
|
|
540 |
selectors:selectors
|
|
541 |
receiver:self
|
|
542 |
!
|
|
543 |
|
45
|
544 |
realize
|
|
545 |
super realize.
|
|
546 |
updateBlock notNil ifTrue:[
|
93
|
547 |
Processor addTimedBlock:updateBlock afterSeconds:updateInterval.
|
45
|
548 |
] ifFalse:[
|
93
|
549 |
myProcess := [
|
|
550 |
|d|
|
45
|
551 |
|
93
|
552 |
[true] whileTrue:[
|
|
553 |
(Delay forSeconds:updateInterval) wait.
|
|
554 |
self updateDisplay
|
|
555 |
]
|
|
556 |
] forkAt:6.
|
|
557 |
myProcess name:'monitor [' ,
|
|
558 |
Processor activeProcess id printString ,
|
|
559 |
'] update'
|
45
|
560 |
].
|
|
561 |
|
|
562 |
newColor := newColor on:device.
|
|
563 |
freeColor := freeColor on:device.
|
|
564 |
oldColor := oldColor on:device.
|
|
565 |
|
|
566 |
font := font on:device.
|
|
567 |
!
|
|
568 |
|
|
569 |
initialize
|
|
570 |
super initialize.
|
|
571 |
|
|
572 |
updateInterval := 0.5.
|
|
573 |
ProcessorScheduler isPureEventDriven ifTrue:[
|
|
574 |
updateBlock := [self updateDisplay].
|
|
575 |
].
|
|
576 |
oldData := Array new:1000.
|
|
577 |
newData := Array new:1000.
|
|
578 |
freeData := Array new:1000.
|
|
579 |
|
|
580 |
updateIndex := 1.
|
52
|
581 |
org := font widthOf:'max 99999k'.
|
|
582 |
level := 0.
|
45
|
583 |
|
57
|
584 |
maxTotal := minTotal := ObjectMemory oldSpaceSize
|
91
|
585 |
+ ObjectMemory symSpaceSize
|
57
|
586 |
+ ObjectMemory newSpaceSize.
|
49
|
587 |
|
45
|
588 |
viewBackground := Black.
|
|
589 |
|
|
590 |
device hasColors ifTrue:[
|
109
|
591 |
newColor := Color orange. "/ yellow.
|
45
|
592 |
freeColor := Color green.
|
|
593 |
oldColor := Color white.
|
|
594 |
] ifFalse:[
|
|
595 |
newColor := Color grey:67.
|
|
596 |
freeColor := Color grey:33.
|
|
597 |
oldColor := Color white.
|
|
598 |
].
|
|
599 |
|
|
600 |
self font:(Font family:'courier' face:'medium' style:'roman' size:10).
|
|
601 |
|
75
|
602 |
self model:self.
|
|
603 |
self menu:#memoryMenu
|
|
604 |
|
45
|
605 |
"
|
|
606 |
MemoryMonitor open
|
|
607 |
"
|
|
608 |
! !
|
|
609 |
|
52
|
610 |
!MemoryMonitor methodsFor:'menu functions'!
|
|
611 |
|
105
|
612 |
cleanupMemory
|
|
613 |
"let all classes release unneeded, cached
|
|
614 |
data ..."
|
|
615 |
|
|
616 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
617 |
aClass lowSpaceCleanup
|
|
618 |
].
|
|
619 |
"
|
|
620 |
then, perform a GC (incl. symbol reclamation)
|
|
621 |
"
|
|
622 |
ObjectMemory reclaimSymbols.
|
|
623 |
"
|
|
624 |
finally, compress
|
|
625 |
"
|
|
626 |
ObjectMemory verboseGarbageCollect.
|
|
627 |
!
|
|
628 |
|
156
|
629 |
resetStatisticValues
|
|
630 |
ObjectMemory resetMaxDelay.
|
|
631 |
ObjectMemory resetMinScavengeReclamation.
|
|
632 |
|
|
633 |
"Created: 7.11.1995 / 17:44:59 / cg"
|
|
634 |
!
|
|
635 |
|
52
|
636 |
garbageCollect
|
|
637 |
ObjectMemory markAndSweep
|
|
638 |
!
|
|
639 |
|
105
|
640 |
garbageCollectAndSymbols
|
|
641 |
ObjectMemory reclaimSymbols
|
|
642 |
!
|
|
643 |
|
52
|
644 |
compressingGarbageCollect
|
|
645 |
ObjectMemory verboseGarbageCollect
|
|
646 |
!
|
|
647 |
|
105
|
648 |
scavenge
|
|
649 |
ObjectMemory scavenge
|
|
650 |
!
|
|
651 |
|
|
652 |
tenure
|
|
653 |
ObjectMemory tenure
|
|
654 |
!
|
|
655 |
|
75
|
656 |
compressSources
|
|
657 |
Smalltalk compressSources.
|
|
658 |
ObjectMemory markAndSweep
|
85
|
659 |
!
|
|
660 |
|
109
|
661 |
incrementalCollect
|
|
662 |
[
|
|
663 |
[ObjectMemory gcStep] whileFalse:[(Delay forMilliseconds:1) wait]
|
|
664 |
] forkAt:Processor highestPriority
|
|
665 |
!
|
|
666 |
|
85
|
667 |
backgroundCollect
|
|
668 |
[ObjectMemory incrementalGC] forkAt:5
|
52
|
669 |
! !
|