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