author | Claus Gittinger <cg@exept.de> |
Tue, 21 Jan 1997 00:21:09 +0100 | |
changeset 972 | 7f8884cb99e2 |
parent 844 | 95fde6837db3 |
child 989 | 0f047353b974 |
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 |
||
798 | 22 |
!MemoryMonitor class methodsFor:'documentation'! |
49 | 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: |
|
512 | 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.) |
|
49 | 46 |
|
512 | 47 |
all current oldSpace in use + newSpace in use |
49 | 48 |
|
512 | 49 |
new current newSpace in use |
49 | 50 |
|
512 | 51 |
frl free space in (fragmented) free lists |
52 |
fre compact free area above the used oldSpace |
|
49 | 53 |
|
512 | 54 |
old current oldSpace in use |
49 | 55 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
56 |
cod dynamic compiled code space size (just in time compiler) |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
57 |
|
512 | 58 |
max, extreme values of 'tot' since the monitor started |
59 |
min (can be reset by typing 'r' in the view) |
|
49 | 60 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
61 |
t tenure threshold (1 .. 30) |
49 | 62 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
63 |
I incremental GC state (2 = idle) |
49 | 64 |
|
512 | 65 |
weak number of weak objects |
109 | 66 |
|
512 | 67 |
rem size of rememberedSet |
108 | 68 |
|
512 | 69 |
minsc: percent of newspace remaining after scavenge (worst case) |
70 |
(i.e. the minimum %% of scavenged objects) |
|
108 | 71 |
|
512 | 72 |
count number of scavenges since system started |
108 | 73 |
|
512 | 74 |
% percentage of live objects in newSpace after last scavenge |
75 |
(i.e. this is the garbage vs. living objects ratio of |
|
76 |
newSpace objects after the last scavenge) |
|
52 | 77 |
|
49 | 78 |
the graphic shows: |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
79 |
orange newSpace used |
512 | 80 |
green free memory in freeLists |
81 |
white oldSpace used |
|
52 | 82 |
|
83 |
||
84 |
the popupMenu offers GC functions; keyboard options are: |
|
512 | 85 |
'f' -> faster; 's' -> slower; 'r' -> reset min/max |
86 |
||
87 |
[author:] |
|
88 |
Claus Gittinger |
|
89 |
||
90 |
[see also:] |
|
91 |
ObjectMemory |
|
92 |
MemoryUsageMonitor ProcessMonitor |
|
49 | 93 |
" |
94 |
! ! |
|
95 |
||
798 | 96 |
!MemoryMonitor class methodsFor:'defaults'! |
49 | 97 |
|
98 |
defaultExtent |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
99 |
^ (200 @ 320) |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
100 |
|
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
101 |
"Modified: 24.8.1996 / 12:04:21 / cg" |
52 | 102 |
! |
19 | 103 |
|
52 | 104 |
defaultIcon |
105 |
|i| |
|
19 | 106 |
|
93 | 107 |
i := Image fromFile:'MemMonitor.xbm'. |
52 | 108 |
i notNil ifTrue:[^ i]. |
109 |
^ super defaultIcon |
|
311 | 110 |
! |
111 |
||
112 |
defaultLabel |
|
113 |
^ 'Memory Monitor' |
|
114 |
! ! |
|
115 |
||
116 |
!MemoryMonitor methodsFor:'destroying'! |
|
117 |
||
118 |
destroy |
|
119 |
updateBlock notNil ifTrue:[ |
|
120 |
Processor removeTimedBlock:updateBlock. |
|
121 |
] ifFalse:[ |
|
122 |
myProcess terminate. |
|
123 |
myProcess := nil |
|
124 |
]. |
|
125 |
oldData := newData := freeData := nil. |
|
126 |
super destroy |
|
19 | 127 |
! ! |
128 |
||
129 |
!MemoryMonitor methodsFor:'drawing'! |
|
130 |
||
798 | 131 |
displayKilo:aNumber name:nm y:y |
132 |
|s| |
|
133 |
||
134 |
s := nm , ((aNumber // 1024) printStringLeftPaddedTo:5) , 'k '. |
|
135 |
self displayOpaqueString:s x:0 y:y. |
|
136 |
||
137 |
! |
|
138 |
||
311 | 139 |
redraw |
140 |
"redraw all" |
|
49 | 141 |
|
311 | 142 |
self clear. |
143 |
self redrawX:0 y:0 width:width height:height |
|
49 | 144 |
! |
145 |
||
146 |
redrawX:x y:y width:w height:h |
|
147 |
"redraw data" |
|
148 |
||
107 | 149 |
|total oldSpaceUsed newSpaceUsed freeMem lx startIdx endIdx |
52 | 150 |
right| |
49 | 151 |
|
152 |
shown ifFalse:[^ self]. |
|
153 |
||
52 | 154 |
right := x + w - 1. |
155 |
right >= org ifTrue:[ |
|
49 | 156 |
lx := x. |
157 |
lx < org ifTrue:[ |
|
158 |
lx := org |
|
159 |
]. |
|
160 |
||
91 | 161 |
total := ObjectMemory symSpaceSize |
57 | 162 |
+ ObjectMemory oldSpaceSize |
163 |
+ ObjectMemory newSpaceSize. |
|
49 | 164 |
|
52 | 165 |
startIdx := (lx-org+1). |
49 | 166 |
startIdx < 1 ifTrue:[ |
167 |
startIdx := 1 |
|
168 |
]. |
|
169 |
||
52 | 170 |
endIdx := right-org+1. |
49 | 171 |
endIdx >= updateIndex ifTrue:[ |
172 |
endIdx := updateIndex-1. |
|
173 |
]. |
|
174 |
dX := 0. |
|
175 |
||
176 |
startIdx to:endIdx do:[:i | |
|
177 |
newSpaceUsed := newData at:i. |
|
178 |
newSpaceUsed notNil ifTrue:[ |
|
179 |
oldSpaceUsed := oldData at:i. |
|
180 |
freeMem := freeData at:i. |
|
181 |
||
182 |
self updateLineX:lx - dX |
|
183 |
total:total |
|
184 |
old:oldSpaceUsed |
|
185 |
new:newSpaceUsed |
|
52 | 186 |
free:freeMem. |
49 | 187 |
]. |
188 |
lx := lx + 1 |
|
189 |
] |
|
190 |
]. |
|
191 |
||
192 |
x < org ifTrue:[ |
|
193 |
prevFree := prevFree2 := prevOld := prevTotal := nil. |
|
194 |
||
195 |
self updateNumbers. |
|
196 |
] |
|
197 |
! |
|
198 |
||
311 | 199 |
updateDisplay |
200 |
"update picture; trigger next update" |
|
201 |
||
202 |
|total oldSpaceUsed newSpaceUsed freeMem oldSpaceSize |
|
203 |
gWidth shift scaleChange margin mustWait| |
|
204 |
||
205 |
shown ifTrue:[ |
|
206 |
oldSpaceUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed. |
|
207 |
newSpaceUsed := ObjectMemory newSpaceUsed. |
|
208 |
freeMem := ObjectMemory freeListSpace + (ObjectMemory oldSpaceSize - ObjectMemory oldSpaceUsed). |
|
209 |
oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize. |
|
210 |
total := oldSpaceSize + ObjectMemory newSpaceSize. |
|
211 |
||
212 |
scaleChange := false. |
|
213 |
||
214 |
((total - freeMem) < minTotal) ifTrue:[ |
|
215 |
minTotal := total - freeMem. |
|
216 |
scaleChange := true |
|
217 |
]. |
|
218 |
(total > maxTotal) ifTrue:[ |
|
219 |
maxTotal := total. |
|
220 |
scaleChange := true |
|
221 |
]. |
|
222 |
||
223 |
oldData at:updateIndex put:oldSpaceSize. "/ oldSpaceUsed. |
|
224 |
newData at:updateIndex put:newSpaceUsed. |
|
225 |
freeData at:updateIndex put:freeMem. |
|
226 |
updateIndex := updateIndex + 1. |
|
227 |
||
228 |
scaleChange ifTrue:[ |
|
229 |
scale := height asFloat / (maxTotal + 100000). |
|
230 |
self redraw |
|
231 |
]. |
|
232 |
||
233 |
gWidth := width - org. |
|
234 |
margin := 1. |
|
235 |
||
236 |
mustWait := false. |
|
237 |
((updateIndex-1) >= (gWidth - margin)) ifTrue:[ |
|
238 |
"on slow displays, use:" |
|
239 |
"/ shift := gWidth // 4. |
|
240 |
||
241 |
"for smooth display, use:" |
|
242 |
shift := 1. |
|
243 |
||
244 |
oldData replaceFrom:1 with:oldData startingAt:shift+1. |
|
245 |
newData replaceFrom:1 with:newData startingAt:shift+1. |
|
246 |
freeData replaceFrom:1 with:freeData startingAt:shift+1. |
|
247 |
||
248 |
updateIndex := updateIndex - shift. |
|
249 |
dX := dX + shift. |
|
250 |
||
251 |
self catchExpose. |
|
252 |
self copyFrom:self |
|
253 |
x:(org + shift) y:0 |
|
254 |
toX:org y:0 |
|
255 |
width:(gWidth - shift - margin) |
|
256 |
height:height. |
|
257 |
self clearRectangleX:(width - margin - shift) y:0 |
|
258 |
width:shift height:height. |
|
259 |
mustWait := true. |
|
260 |
]. |
|
261 |
||
262 |
self updateLineX:(updateIndex - 1 + org - 1) |
|
263 |
total:total |
|
264 |
old:oldSpaceSize "/ oldSpaceUsed |
|
265 |
new:newSpaceUsed |
|
266 |
free:freeMem. |
|
267 |
||
268 |
self updateNumbers. |
|
269 |
self flush. |
|
270 |
mustWait ifTrue:[ |
|
271 |
self waitForExpose. |
|
272 |
] |
|
273 |
||
274 |
]. |
|
275 |
||
276 |
updateBlock notNil ifTrue:[ |
|
277 |
Processor addTimedBlock:updateBlock afterSeconds:updateInterval |
|
278 |
]. |
|
279 |
||
280 |
"Modified: 18.12.1995 / 15:21:10 / cg" |
|
281 |
! |
|
282 |
||
109 | 283 |
updateLineX:x total:total old:oldSpaceSize new:newSpaceUsed free:freeMem |
284 |
|hNew hOld hFree y1 y2 y3| |
|
49 | 285 |
|
286 |
hNew := (newSpaceUsed * scale) asInteger. |
|
109 | 287 |
hOld := (oldSpaceSize * scale) // 2. |
288 |
hFree := (freeMem * scale) // 2. |
|
49 | 289 |
|
290 |
y1 := height - 1. |
|
109 | 291 |
|
49 | 292 |
y2 := y1 - hOld. |
293 |
self paint:oldColor. |
|
294 |
self displayLineFromX:x y:y1 toX:x y:y2. |
|
295 |
||
109 | 296 |
y3 := y1 - hFree. |
49 | 297 |
self paint:freeColor. |
109 | 298 |
self displayLineFromX:x y:y1 toX:x y:y3. |
49 | 299 |
|
109 | 300 |
y1 := y2 - hNew. |
49 | 301 |
self paint:newColor. |
302 |
self displayLineFromX:x y:y1 toX:x y:y2. |
|
303 |
! |
|
304 |
||
305 |
updateNumbers |
|
306 |
"redraw numbers. |
|
307 |
The values shown are: |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
308 |
max: maximum memory used since monitor started |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
309 |
min: minimum memory used since monitor started |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
310 |
tot: total memory used (overall oldSpace + overall newSpace) |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
311 |
all: current memory in use (oldSpace + newSpace) |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
312 |
new: current newSpace in use |
735 | 313 |
fre: current size of freelist in oldSpace |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
314 |
old: current oldSpace in use |
735 | 315 |
code: current just-in-time compiled code cache size |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
316 |
t: current tenure age |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
317 |
I: IGC state |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
318 |
weak: number of weak arrays in the system |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
319 |
rem remembered set size |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
320 |
lrem lifo remembered set size |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
321 |
minsc: percent of newspace remaining after scavenge (worst case) |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
322 |
irq: max. interrupt delay |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
323 |
count of scavenges / last scavenge survivor rate |
156 | 324 |
|
49 | 325 |
" |
326 |
||
327 |
|oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 |
|
107 | 328 |
y half s fontHeight total n| |
49 | 329 |
|
91 | 330 |
oldMemUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed. |
49 | 331 |
newMemUsed := ObjectMemory newSpaceUsed. |
332 |
freeMem := ObjectMemory freeListSpace. |
|
91 | 333 |
oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize. |
49 | 334 |
newSpaceSize := ObjectMemory newSpaceSize. |
335 |
||
336 |
memUsed := oldMemUsed + newMemUsed "- freeMem". |
|
337 |
total := oldSpaceSize + newSpaceSize. |
|
68 | 338 |
free2 := ObjectMemory freeSpace. |
49 | 339 |
|
340 |
self paint:White on:Black. |
|
341 |
||
342 |
fontHeight := font height + font descent. |
|
343 |
half := height // 2 + font descent. |
|
344 |
||
109 | 345 |
y := half - (fontHeight * 5). |
49 | 346 |
|
347 |
total ~~ prevTotal ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
348 |
((total - freeMem) < minTotal) ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
349 |
minTotal := total - freeMem. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
350 |
]. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
351 |
(total > maxTotal) ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
352 |
maxTotal := total. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
353 |
]. |
52 | 354 |
|
798 | 355 |
self displayKilo:maxTotal name:'max ' y:font ascent. |
356 |
self displayKilo:minTotal name:'min ' y:(height - font descent). |
|
357 |
self displayKilo:total name:'tot ' y:y. |
|
52 | 358 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
359 |
prevTotal := total. |
49 | 360 |
]. |
361 |
||
362 |
y := y + fontHeight. |
|
798 | 363 |
self displayKilo:memUsed name:'all ' y:y. |
49 | 364 |
|
365 |
y := y + fontHeight. |
|
366 |
self paint:newColor. |
|
798 | 367 |
self displayKilo:newMemUsed name:'new ' y:y. |
49 | 368 |
|
369 |
y := y + fontHeight. |
|
370 |
freeMem ~~ prevFree ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
371 |
self paint:freeColor. |
798 | 372 |
self displayKilo:freeMem name:'frl ' y:y. |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
373 |
prevFree := freeMem. |
49 | 374 |
]. |
375 |
||
376 |
y := y + fontHeight. |
|
377 |
free2 ~~ prevFree2 ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
378 |
self paint:freeColor. |
798 | 379 |
self displayKilo:free2 name:'fre ' y:y. |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
380 |
prevFree2 := free2. |
49 | 381 |
]. |
382 |
||
383 |
y := y + fontHeight. |
|
384 |
(oldMemUsed - freeMem) ~~ prevOld ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
385 |
self paint:oldColor. |
798 | 386 |
self displayKilo:(oldMemUsed - freeMem) name:'old ' y:y. |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
387 |
prevOld := (oldMemUsed - freeMem). |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
388 |
]. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
389 |
|
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
390 |
ObjectMemory supportsJustInTimeCompilation ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
391 |
y := y + fontHeight. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
392 |
self paint:oldColor. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
393 |
n := ObjectMemory compiledCodeSpaceUsed. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
394 |
n > 9999 ifTrue:[ |
735 | 395 |
s := 'code ' , ((n // 1024) printStringLeftPaddedTo:4) , 'k'. |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
396 |
] ifFalse:[ |
735 | 397 |
s := 'code ' , (n printStringLeftPaddedTo:4) , ' '. |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
398 |
]. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
399 |
self displayOpaqueString:s x:0 y:y. |
49 | 400 |
]. |
401 |
||
402 |
" |
|
303
1d94813f1977
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
168
diff
changeset
|
403 |
the following is internal - normally only interesting when debugging the VM |
49 | 404 |
" |
405 |
y := y + fontHeight. |
|
406 |
self paint:oldColor. |
|
60 | 407 |
s := 't:' , (ObjectMemory tenureAge printStringLeftPaddedTo:2) , ' '. |
108 | 408 |
s := s , ' I:' , (ObjectMemory incrementalGCPhase printStringLeftPaddedTo:2) , ' '. |
409 |
self displayOpaqueString:s x:0 y:y. |
|
410 |
||
411 |
y := y + fontHeight. |
|
109 | 412 |
s := 'weak: ' , (ObjectMemory numberOfWeakObjects printStringLeftPaddedTo:4). |
413 |
self displayOpaqueString:s x:0 y:y. |
|
414 |
||
415 |
y := y + fontHeight. |
|
108 | 416 |
s := 'rem: ' , (ObjectMemory rememberedSetSize printStringLeftPaddedTo:5). |
49 | 417 |
self displayOpaqueString:s x:0 y:y. |
418 |
||
109 | 419 |
y := y + fontHeight. |
420 |
s := 'lrem: ' , (ObjectMemory lifoRememberedSetSize printStringLeftPaddedTo:4 ifLarger:['****']). |
|
421 |
self displayOpaqueString:s x:0 y:y. |
|
422 |
||
49 | 423 |
"/ does no longer make sense to show .... |
424 |
"/ y := y + fontHeight. |
|
425 |
"/ ObjectMemory runsSingleOldSpace ifTrue:[ |
|
426 |
"/ self displayOpaqueString:'single' x:0 y:(half + (fontHeight*4)). |
|
427 |
"/ ]. |
|
428 |
||
52 | 429 |
y := y + fontHeight. |
108 | 430 |
n := ObjectMemory minScavengeReclamation / ObjectMemory newSpaceSize * 100.0. |
52 | 431 |
n := 100 - n asInteger. |
108 | 432 |
s := 'minSc ', (n printStringLeftPaddedTo:3) , '%'. |
433 |
self displayOpaqueString:s x:0 y:y. |
|
434 |
||
435 |
y := y + fontHeight. |
|
157 | 436 |
n := ObjectMemory maxInterruptLatency. |
156 | 437 |
n notNil ifTrue:[ |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
438 |
s := 'irq ', (n printStringLeftPaddedTo:3) , ' ms'. |
156 | 439 |
] ifFalse:[ |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
440 |
s := '' |
156 | 441 |
]. |
442 |
self displayOpaqueString:s x:0 y:y. |
|
443 |
||
444 |
y := y + fontHeight. |
|
108 | 445 |
n := ObjectMemory lastScavengeReclamation / ObjectMemory newSpaceSize * 100.0. |
446 |
n := 100 - n asInteger. |
|
447 |
s := (ObjectMemory scavengeCount printStringLeftPaddedTo:6) |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
448 |
, (n printStringLeftPaddedTo:3) , '%'. |
52 | 449 |
self displayOpaqueString:s x:0 y:y. |
156 | 450 |
|
451 |
"Created: 7.11.1995 / 14:48:16 / cg" |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
452 |
"Modified: 24.8.1996 / 11:57:22 / cg" |
19 | 453 |
! ! |
454 |
||
455 |
!MemoryMonitor methodsFor:'events'! |
|
456 |
||
311 | 457 |
keyPress:key x:x y:y |
458 |
key == $f ifTrue:[ |
|
459 |
"faster" |
|
460 |
updateInterval := updateInterval / 2 |
|
461 |
]. |
|
462 |
key == $s ifTrue:[ |
|
463 |
"slower" |
|
464 |
updateInterval := updateInterval * 2 |
|
465 |
]. |
|
466 |
key == $r ifTrue:[ |
|
467 |
"reset max" |
|
468 |
maxTotal := prevTotal. |
|
469 |
scale := height asFloat / (maxTotal + 100000). |
|
470 |
self resetStatisticValues. |
|
471 |
self redraw. |
|
472 |
] |
|
473 |
||
474 |
"Modified: 7.11.1995 / 17:45:13 / cg" |
|
475 |
! |
|
476 |
||
49 | 477 |
sizeChanged:how |
478 |
|nn no nf delta oldSize newSize| |
|
479 |
||
480 |
super sizeChanged:how. |
|
19 | 481 |
|
45 | 482 |
oldSize := oldData size. |
49 | 483 |
newSize := width-org+1. |
484 |
||
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
485 |
(newSize ~~ oldSize) ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
486 |
nn := Array new:newSize. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
487 |
no := Array new:newSize. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
488 |
nf := Array new:newSize. |
45 | 489 |
|
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
490 |
(newSize > oldSize) ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
491 |
nn replaceFrom:1 to:oldSize with:newData. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
492 |
no replaceFrom:1 to:oldSize with:oldData. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
493 |
nf replaceFrom:1 to:oldSize with:freeData |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
494 |
] ifFalse:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
495 |
delta := (oldSize - newSize). |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
496 |
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
|
497 |
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
|
498 |
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
|
499 |
updateIndex > newSize ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
500 |
updateIndex := updateIndex - delta. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
501 |
] |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
502 |
]. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
503 |
newData := nn. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
504 |
oldData := no. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
505 |
freeData := nf. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
506 |
|
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
507 |
scale := height asFloat / (maxTotal + 100000). |
19 | 508 |
]. |
52 | 509 |
self clear. |
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
510 |
self redraw. |
19 | 511 |
! ! |
45 | 512 |
|
513 |
!MemoryMonitor methodsFor:'initialization'! |
|
514 |
||
311 | 515 |
initialize |
516 |
super initialize. |
|
517 |
||
518 |
updateInterval := 0.5. |
|
519 |
ProcessorScheduler isPureEventDriven ifTrue:[ |
|
520 |
updateBlock := [self updateDisplay]. |
|
521 |
]. |
|
522 |
oldData := Array new:1000. |
|
523 |
newData := Array new:1000. |
|
524 |
freeData := Array new:1000. |
|
525 |
||
526 |
updateIndex := 1. |
|
527 |
org := font widthOf:'max 99999k'. |
|
528 |
level := 0. |
|
529 |
||
530 |
maxTotal := minTotal := ObjectMemory oldSpaceSize |
|
531 |
+ ObjectMemory symSpaceSize |
|
532 |
+ ObjectMemory newSpaceSize. |
|
533 |
||
534 |
viewBackground := Black. |
|
535 |
||
536 |
device hasColors ifTrue:[ |
|
537 |
newColor := Color orange. "/ yellow. |
|
538 |
freeColor := Color green. |
|
539 |
oldColor := Color white. |
|
540 |
] ifFalse:[ |
|
541 |
newColor := Color grey:67. |
|
542 |
freeColor := Color grey:33. |
|
543 |
oldColor := Color white. |
|
544 |
]. |
|
545 |
||
546 |
self font:(Font family:'courier' face:'medium' style:'roman' size:10). |
|
547 |
||
548 |
self model:self. |
|
549 |
self menu:#memoryMenu |
|
550 |
||
551 |
" |
|
552 |
MemoryMonitor open |
|
553 |
" |
|
554 |
! |
|
555 |
||
85 | 556 |
memoryMenu |
323 | 557 |
|m specialMenu labels selectors| |
558 |
||
559 |
labels := #( |
|
560 |
'scavenge' |
|
561 |
'tenure' |
|
972 | 562 |
'hi prio incremental collect' |
323 | 563 |
'-' |
564 |
'cleanup memory' |
|
844 | 565 |
'flush method history' |
323 | 566 |
'-' |
567 |
'compress sources' |
|
568 |
). |
|
569 |
selectors := #( |
|
570 |
scavenge |
|
571 |
tenure |
|
572 |
incrementalCollect |
|
573 |
nil |
|
574 |
cleanupMemory |
|
844 | 575 |
cleanupMethodHistory |
323 | 576 |
nil |
577 |
compressSources |
|
578 |
). |
|
579 |
||
580 |
specialMenu := PopUpMenu |
|
581 |
labels:(resources array:labels) |
|
582 |
selectors:selectors. |
|
85 | 583 |
|
105 | 584 |
device ctrlDown ifTrue:[ |
323 | 585 |
^ specialMenu |
105 | 586 |
]. |
85 | 587 |
|
972 | 588 |
ObjectMemory backgroundCollectorRunning ifFalse:[ |
589 |
labels := #( |
|
590 |
'collect garbage' |
|
591 |
'collect garbage & symbols' |
|
592 |
'collect garbage & compress' |
|
593 |
'-' |
|
594 |
'background collect now' |
|
595 |
'start background collector' |
|
596 |
'-' |
|
597 |
'reset statistic values' |
|
598 |
'-' |
|
599 |
'others' |
|
600 |
). |
|
323 | 601 |
|
972 | 602 |
selectors := #( |
603 |
garbageCollect |
|
604 |
garbageCollectAndSymbols |
|
605 |
compressingGarbageCollect |
|
606 |
nil |
|
607 |
backgroundCollect |
|
608 |
restartBackgroundCollector |
|
609 |
nil |
|
610 |
resetStatisticValues |
|
611 |
nil |
|
612 |
otherMenu |
|
613 |
). |
|
614 |
] ifTrue:[ |
|
615 |
labels := #( |
|
616 |
'collect garbage' |
|
617 |
'collect garbage & symbols' |
|
618 |
'collect garbage & compress' |
|
619 |
'-' |
|
620 |
'background collect' |
|
621 |
'-' |
|
622 |
'reset statistic values' |
|
623 |
'-' |
|
624 |
'others' |
|
625 |
). |
|
626 |
||
627 |
selectors := #( |
|
628 |
garbageCollect |
|
629 |
garbageCollectAndSymbols |
|
630 |
compressingGarbageCollect |
|
631 |
nil |
|
632 |
backgroundCollect |
|
633 |
nil |
|
634 |
resetStatisticValues |
|
635 |
nil |
|
636 |
otherMenu |
|
637 |
). |
|
638 |
]. |
|
323 | 639 |
m := PopUpMenu labels:(resources array:labels) |
640 |
selectors:selectors. |
|
641 |
||
642 |
m subMenuAt:#otherMenu put:specialMenu. |
|
643 |
^ m |
|
972 | 644 |
|
645 |
"Modified: 21.1.1997 / 00:20:27 / cg" |
|
85 | 646 |
! |
647 |
||
45 | 648 |
realize |
649 |
super realize. |
|
650 |
updateBlock notNil ifTrue:[ |
|
93 | 651 |
Processor addTimedBlock:updateBlock afterSeconds:updateInterval. |
45 | 652 |
] ifFalse:[ |
93 | 653 |
myProcess := [ |
654 |
|d| |
|
45 | 655 |
|
93 | 656 |
[true] whileTrue:[ |
657 |
(Delay forSeconds:updateInterval) wait. |
|
658 |
self updateDisplay |
|
659 |
] |
|
660 |
] forkAt:6. |
|
661 |
myProcess name:'monitor [' , |
|
662 |
Processor activeProcess id printString , |
|
663 |
'] update' |
|
45 | 664 |
]. |
665 |
||
666 |
newColor := newColor on:device. |
|
667 |
freeColor := freeColor on:device. |
|
668 |
oldColor := oldColor on:device. |
|
669 |
||
670 |
font := font on:device. |
|
671 |
! ! |
|
672 |
||
52 | 673 |
!MemoryMonitor methodsFor:'menu functions'! |
674 |
||
311 | 675 |
backgroundCollect |
676 |
"start a background (non disturbing) incremental GC. |
|
677 |
Since the GC is performed at a low priority, it may not make progress if higher |
|
678 |
prio processes are running" |
|
679 |
||
680 |
[ |
|
681 |
ObjectMemory incrementalGC |
|
682 |
] forkAt:5 |
|
683 |
! |
|
684 |
||
105 | 685 |
cleanupMemory |
686 |
"let all classes release unneeded, cached |
|
687 |
data ..." |
|
688 |
||
469
3653317928e2
dont repeat coding in ObjectMemory ...
Claus Gittinger <cg@exept.de>
parents:
360
diff
changeset
|
689 |
ObjectMemory performLowSpaceCleanup. |
3653317928e2
dont repeat coding in ObjectMemory ...
Claus Gittinger <cg@exept.de>
parents:
360
diff
changeset
|
690 |
|
105 | 691 |
" |
692 |
then, perform a GC (incl. symbol reclamation) |
|
693 |
" |
|
694 |
ObjectMemory reclaimSymbols. |
|
695 |
" |
|
696 |
finally, compress |
|
697 |
" |
|
698 |
ObjectMemory verboseGarbageCollect. |
|
699 |
! |
|
700 |
||
844 | 701 |
cleanupMethodHistory |
702 |
"release the oldMethod history" |
|
703 |
||
704 |
(self confirm:'This removes the previous method history, |
|
705 |
which is kept for all changed methods in the system. |
|
706 |
After that, the browsers cannot easily switch back to a methods |
|
707 |
previous version. |
|
708 |
||
709 |
However, this is normally not a problem, since |
|
710 |
a methods previous code should still be accessable through |
|
711 |
either the changes-file, the sourceCode repository or the classes original |
|
712 |
source file. |
|
713 |
||
714 |
cleanup now ?') ifTrue:[ |
|
715 |
||
716 |
||
717 |
Class flushMethodHistory. |
|
718 |
||
719 |
" |
|
720 |
then, perform a GC (incl. symbol reclamation) |
|
721 |
" |
|
722 |
ObjectMemory reclaimSymbols. |
|
723 |
" |
|
724 |
finally, compress |
|
725 |
" |
|
726 |
ObjectMemory verboseGarbageCollect. |
|
727 |
] |
|
728 |
||
729 |
||
730 |
||
731 |
! |
|
732 |
||
311 | 733 |
compressSources |
323 | 734 |
(self confirm:'This saves all in-memory source strings into a file |
360 | 735 |
and makes methods reference these (file-) strings, |
736 |
freeing all in-memory sources. |
|
323 | 737 |
|
738 |
If that source file is ever lost or gets out of sync with |
|
739 |
your system, those method sources are lost and the browser |
|
740 |
will show garbage. |
|
741 |
However, you still have a change file as backup. |
|
742 |
||
743 |
(Be especially careful, if you move images around: |
|
360 | 744 |
the source file must then be the correct one for that image) |
323 | 745 |
|
746 |
A compress is only useful, if you added many methods |
|
747 |
and the systems response time suffers from paging. |
|
748 |
||
749 |
Compress anyway ?') ifTrue:[ |
|
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
750 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
751 |
Smalltalk compressSources. |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
752 |
ObjectMemory markAndSweep |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
753 |
] |
323 | 754 |
] |
755 |
||
360 | 756 |
"Modified: 9.2.1996 / 18:17:22 / cg" |
311 | 757 |
! |
156 | 758 |
|
311 | 759 |
compressingGarbageCollect |
760 |
"perform a blocking compressing garbage collect." |
|
761 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
762 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
763 |
ObjectMemory verboseGarbageCollect |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
764 |
] |
156 | 765 |
! |
766 |
||
52 | 767 |
garbageCollect |
159 | 768 |
"perform a blocking (non compressing) garbage collect" |
769 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
770 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
771 |
ObjectMemory markAndSweep |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
772 |
] |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
773 |
|
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
774 |
"Modified: 2.1.1996 / 12:17:33 / cg" |
52 | 775 |
! |
776 |
||
105 | 777 |
garbageCollectAndSymbols |
159 | 778 |
"perform a blocking (non compressing) garbage collect |
779 |
and reclaim unreferenced symbols." |
|
780 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
781 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
782 |
ObjectMemory reclaimSymbols |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
783 |
] |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
784 |
|
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
785 |
"Modified: 2.1.1996 / 12:17:36 / cg" |
105 | 786 |
! |
787 |
||
311 | 788 |
incrementalCollect |
789 |
"start an incremental GC which does not disturb too much, but is guaranteed to |
|
790 |
make progress. |
|
323 | 791 |
This is done by doing the IGC at a very high priority, but giving up the CPU after |
792 |
every step. Due to the long delays, this may take a while to finish. |
|
793 |
Notice, that this is different from doing a background collect: that one |
|
794 |
may not make any progress if higher prio processes are runnable." |
|
795 |
||
796 |
|done delay| |
|
797 |
||
311 | 798 |
[ |
323 | 799 |
done := false. |
800 |
delay := Delay new. |
|
801 |
[done] whileFalse:[ |
|
802 |
10 timesRepeat:[ |
|
803 |
done ifFalse:[done := ObjectMemory gcStep]. |
|
804 |
]. |
|
805 |
(delay delay:10) wait |
|
806 |
] |
|
311 | 807 |
] forkAt:Processor highestPriority |
323 | 808 |
|
809 |
"Modified: 23.12.1995 / 17:31:55 / cg" |
|
311 | 810 |
! |
159 | 811 |
|
311 | 812 |
resetStatisticValues |
813 |
ObjectMemory resetMaxInterruptLatency. |
|
814 |
ObjectMemory resetMinScavengeReclamation. |
|
815 |
||
816 |
"Created: 7.11.1995 / 17:44:59 / cg" |
|
52 | 817 |
! |
818 |
||
972 | 819 |
restartBackgroundCollector |
820 |
"start a background (non disturbing) incremental GC. |
|
821 |
Since the GC is performed at a low priority, it may not make progress if higher |
|
822 |
prio processes are running" |
|
823 |
||
824 |
ObjectMemory backgroundCollectorRunning |
|
825 |
ifFalse:[ |
|
826 |
ObjectMemory startBackgroundCollectorAt:5. |
|
827 |
ObjectMemory startBackgroundCollectorAt:5 |
|
828 |
] |
|
829 |
||
830 |
"Created: 21.1.1997 / 00:09:30 / cg" |
|
831 |
! |
|
832 |
||
105 | 833 |
scavenge |
159 | 834 |
"perform a blocking newspace garbage collect. |
835 |
(this is for debugging only - the system does this automatically)" |
|
836 |
||
105 | 837 |
ObjectMemory scavenge |
838 |
! |
|
839 |
||
840 |
tenure |
|
159 | 841 |
"empty the newSpace, by aging all new objects immediately and transfering them |
842 |
into oldSpace. |
|
843 |
(this is for debugging only - the system does this automatically)" |
|
844 |
||
105 | 845 |
ObjectMemory tenure |
311 | 846 |
! ! |
105 | 847 |
|
798 | 848 |
!MemoryMonitor class methodsFor:'documentation'! |
85 | 849 |
|
311 | 850 |
version |
972 | 851 |
^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.40 1997-01-20 23:21:09 cg Exp $' |
52 | 852 |
! ! |