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