author | Claus Gittinger <cg@exept.de> |
Sat, 24 Aug 1996 12:07:24 +0200 | |
changeset 696 | b55f8705bb41 |
parent 517 | cc3d4e0fc758 |
child 735 | 600fe3dab131 |
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 |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
305 |
free: current size of freelist in oldSpace |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
306 |
old: current oldSpace in use |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
307 |
t: current tenure age |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
308 |
I: IGC state |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
309 |
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
|
310 |
rem remembered set size |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
311 |
lrem lifo remembered set size |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
312 |
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
|
313 |
irq: max. interrupt delay |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
314 |
count of scavenges / last scavenge survivor rate |
156 | 315 |
|
49 | 316 |
" |
317 |
||
318 |
|oldSpaceSize newSpaceSize memUsed oldMemUsed newMemUsed freeMem free2 |
|
107 | 319 |
y half s fontHeight total n| |
49 | 320 |
|
91 | 321 |
oldMemUsed := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed. |
49 | 322 |
newMemUsed := ObjectMemory newSpaceUsed. |
323 |
freeMem := ObjectMemory freeListSpace. |
|
91 | 324 |
oldSpaceSize := ObjectMemory oldSpaceSize + ObjectMemory symSpaceSize. |
49 | 325 |
newSpaceSize := ObjectMemory newSpaceSize. |
326 |
||
327 |
memUsed := oldMemUsed + newMemUsed "- freeMem". |
|
328 |
total := oldSpaceSize + newSpaceSize. |
|
68 | 329 |
free2 := ObjectMemory freeSpace. |
49 | 330 |
|
331 |
self paint:White on:Black. |
|
332 |
||
333 |
fontHeight := font height + font descent. |
|
334 |
half := height // 2 + font descent. |
|
335 |
||
109 | 336 |
y := half - (fontHeight * 5). |
49 | 337 |
|
338 |
total ~~ prevTotal ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
339 |
((total - freeMem) < minTotal) ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
340 |
minTotal := total - freeMem. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
341 |
]. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
342 |
(total > maxTotal) ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
343 |
maxTotal := total. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
344 |
]. |
52 | 345 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
346 |
s := 'max ' , ((maxTotal // 1024) printStringLeftPaddedTo:5) , 'k '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
347 |
self displayOpaqueString:s x:0 y:font ascent. |
52 | 348 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
349 |
s := 'min ' , ((minTotal // 1024) printStringLeftPaddedTo:5) , 'k '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
350 |
self displayOpaqueString:s x:0 y:(height - font descent). |
52 | 351 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
352 |
s := 'tot ' , ((total // 1024) printStringLeftPaddedTo:5) , 'k '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
353 |
self displayOpaqueString:s x:0 y:y. |
52 | 354 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
355 |
prevTotal := total. |
49 | 356 |
]. |
357 |
||
358 |
y := y + fontHeight. |
|
60 | 359 |
s := 'all ' , ((memUsed // 1024) printStringLeftPaddedTo:5) , 'k '. |
49 | 360 |
self displayOpaqueString:s x:0 y:y. |
361 |
||
362 |
y := y + fontHeight. |
|
363 |
self paint:newColor. |
|
60 | 364 |
s := 'new ' , ((newMemUsed // 1024) printStringLeftPaddedTo:5) , 'k '. |
49 | 365 |
self displayOpaqueString:s x:0 y:y. |
366 |
||
367 |
y := y + fontHeight. |
|
368 |
freeMem ~~ prevFree ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
369 |
self paint:freeColor. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
370 |
s := 'frl ' , ((freeMem // 1024) printStringLeftPaddedTo:5) , 'k '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
371 |
self displayOpaqueString:s x:0 y:y. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
372 |
prevFree := freeMem. |
49 | 373 |
]. |
374 |
||
375 |
y := y + fontHeight. |
|
376 |
free2 ~~ prevFree2 ifTrue:[ |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
377 |
self paint:freeColor. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
378 |
s := 'fre ' , ((free2 // 1024) printStringLeftPaddedTo:5) , 'k '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
379 |
self displayOpaqueString:s x:0 y:y. |
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. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
386 |
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
|
387 |
self displayOpaqueString:s x:0 y:y. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
388 |
prevOld := (oldMemUsed - freeMem). |
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 |
|
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
391 |
ObjectMemory supportsJustInTimeCompilation ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
392 |
y := y + fontHeight. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
393 |
self paint:oldColor. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
394 |
n := ObjectMemory compiledCodeSpaceUsed. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
395 |
n > 9999 ifTrue:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
396 |
s := 'cod ' , ((n // 1024) printStringLeftPaddedTo:5) , 'k'. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
397 |
] ifFalse:[ |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
398 |
s := 'cod ' , (n printStringLeftPaddedTo:5) , ' '. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
399 |
]. |
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
400 |
self displayOpaqueString:s x:0 y:y. |
49 | 401 |
]. |
402 |
||
403 |
" |
|
303
1d94813f1977
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
168
diff
changeset
|
404 |
the following is internal - normally only interesting when debugging the VM |
49 | 405 |
" |
406 |
y := y + fontHeight. |
|
407 |
self paint:oldColor. |
|
60 | 408 |
s := 't:' , (ObjectMemory tenureAge printStringLeftPaddedTo:2) , ' '. |
108 | 409 |
s := s , ' I:' , (ObjectMemory incrementalGCPhase printStringLeftPaddedTo:2) , ' '. |
410 |
self displayOpaqueString:s x:0 y:y. |
|
411 |
||
412 |
y := y + fontHeight. |
|
109 | 413 |
s := 'weak: ' , (ObjectMemory numberOfWeakObjects printStringLeftPaddedTo:4). |
414 |
self displayOpaqueString:s x:0 y:y. |
|
415 |
||
416 |
y := y + fontHeight. |
|
108 | 417 |
s := 'rem: ' , (ObjectMemory rememberedSetSize printStringLeftPaddedTo:5). |
49 | 418 |
self displayOpaqueString:s x:0 y:y. |
419 |
||
109 | 420 |
y := y + fontHeight. |
421 |
s := 'lrem: ' , (ObjectMemory lifoRememberedSetSize printStringLeftPaddedTo:4 ifLarger:['****']). |
|
422 |
self displayOpaqueString:s x:0 y:y. |
|
423 |
||
49 | 424 |
"/ does no longer make sense to show .... |
425 |
"/ y := y + fontHeight. |
|
426 |
"/ ObjectMemory runsSingleOldSpace ifTrue:[ |
|
427 |
"/ self displayOpaqueString:'single' x:0 y:(half + (fontHeight*4)). |
|
428 |
"/ ]. |
|
429 |
||
52 | 430 |
y := y + fontHeight. |
108 | 431 |
n := ObjectMemory minScavengeReclamation / ObjectMemory newSpaceSize * 100.0. |
52 | 432 |
n := 100 - n asInteger. |
108 | 433 |
s := 'minSc ', (n printStringLeftPaddedTo:3) , '%'. |
434 |
self displayOpaqueString:s x:0 y:y. |
|
435 |
||
436 |
y := y + fontHeight. |
|
157 | 437 |
n := ObjectMemory maxInterruptLatency. |
156 | 438 |
n notNil ifTrue:[ |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
439 |
s := 'irq ', (n printStringLeftPaddedTo:3) , ' ms'. |
156 | 440 |
] ifFalse:[ |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
441 |
s := '' |
156 | 442 |
]. |
443 |
self displayOpaqueString:s x:0 y:y. |
|
444 |
||
445 |
y := y + fontHeight. |
|
108 | 446 |
n := ObjectMemory lastScavengeReclamation / ObjectMemory newSpaceSize * 100.0. |
447 |
n := 100 - n asInteger. |
|
448 |
s := (ObjectMemory scavengeCount printStringLeftPaddedTo:6) |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
449 |
, (n printStringLeftPaddedTo:3) , '%'. |
52 | 450 |
self displayOpaqueString:s x:0 y:y. |
156 | 451 |
|
452 |
"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
|
453 |
"Modified: 24.8.1996 / 11:57:22 / cg" |
19 | 454 |
! ! |
455 |
||
456 |
!MemoryMonitor methodsFor:'events'! |
|
457 |
||
311 | 458 |
keyPress:key x:x y:y |
459 |
key == $f ifTrue:[ |
|
460 |
"faster" |
|
461 |
updateInterval := updateInterval / 2 |
|
462 |
]. |
|
463 |
key == $s ifTrue:[ |
|
464 |
"slower" |
|
465 |
updateInterval := updateInterval * 2 |
|
466 |
]. |
|
467 |
key == $r ifTrue:[ |
|
468 |
"reset max" |
|
469 |
maxTotal := prevTotal. |
|
470 |
scale := height asFloat / (maxTotal + 100000). |
|
471 |
self resetStatisticValues. |
|
472 |
self redraw. |
|
473 |
] |
|
474 |
||
475 |
"Modified: 7.11.1995 / 17:45:13 / cg" |
|
476 |
! |
|
477 |
||
49 | 478 |
sizeChanged:how |
479 |
|nn no nf delta oldSize newSize| |
|
480 |
||
481 |
super sizeChanged:how. |
|
19 | 482 |
|
45 | 483 |
oldSize := oldData size. |
49 | 484 |
newSize := width-org+1. |
485 |
||
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
486 |
(newSize ~~ oldSize) ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
487 |
nn := Array new:newSize. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
488 |
no := Array new:newSize. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
489 |
nf := Array new:newSize. |
45 | 490 |
|
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
491 |
(newSize > oldSize) ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
492 |
nn replaceFrom:1 to:oldSize with:newData. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
493 |
no replaceFrom:1 to:oldSize with:oldData. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
494 |
nf replaceFrom:1 to:oldSize with:freeData |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
495 |
] ifFalse:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
496 |
delta := (oldSize - newSize). |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
497 |
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
|
498 |
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
|
499 |
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
|
500 |
updateIndex > newSize ifTrue:[ |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
501 |
updateIndex := updateIndex - delta. |
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 |
]. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
504 |
newData := nn. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
505 |
oldData := no. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
506 |
freeData := nf. |
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
507 |
|
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
508 |
scale := height asFloat / (maxTotal + 100000). |
19 | 509 |
]. |
52 | 510 |
self clear. |
168
0ca5ca046b22
Redraw text on vertical window size changes.
Stefan Vogel <sv@exept.de>
parents:
165
diff
changeset
|
511 |
self redraw. |
19 | 512 |
! ! |
45 | 513 |
|
514 |
!MemoryMonitor methodsFor:'initialization'! |
|
515 |
||
311 | 516 |
initialize |
517 |
super initialize. |
|
518 |
||
519 |
updateInterval := 0.5. |
|
520 |
ProcessorScheduler isPureEventDriven ifTrue:[ |
|
521 |
updateBlock := [self updateDisplay]. |
|
522 |
]. |
|
523 |
oldData := Array new:1000. |
|
524 |
newData := Array new:1000. |
|
525 |
freeData := Array new:1000. |
|
526 |
||
527 |
updateIndex := 1. |
|
528 |
org := font widthOf:'max 99999k'. |
|
529 |
level := 0. |
|
530 |
||
531 |
maxTotal := minTotal := ObjectMemory oldSpaceSize |
|
532 |
+ ObjectMemory symSpaceSize |
|
533 |
+ ObjectMemory newSpaceSize. |
|
534 |
||
535 |
viewBackground := Black. |
|
536 |
||
537 |
device hasColors ifTrue:[ |
|
538 |
newColor := Color orange. "/ yellow. |
|
539 |
freeColor := Color green. |
|
540 |
oldColor := Color white. |
|
541 |
] ifFalse:[ |
|
542 |
newColor := Color grey:67. |
|
543 |
freeColor := Color grey:33. |
|
544 |
oldColor := Color white. |
|
545 |
]. |
|
546 |
||
547 |
self font:(Font family:'courier' face:'medium' style:'roman' size:10). |
|
548 |
||
549 |
self model:self. |
|
550 |
self menu:#memoryMenu |
|
551 |
||
552 |
" |
|
553 |
MemoryMonitor open |
|
554 |
" |
|
555 |
! |
|
556 |
||
85 | 557 |
memoryMenu |
323 | 558 |
|m specialMenu labels selectors| |
559 |
||
560 |
labels := #( |
|
561 |
'scavenge' |
|
562 |
'tenure' |
|
563 |
'incremental collect' |
|
564 |
'-' |
|
565 |
'cleanup memory' |
|
566 |
'-' |
|
567 |
'compress sources' |
|
568 |
). |
|
569 |
selectors := #( |
|
570 |
scavenge |
|
571 |
tenure |
|
572 |
incrementalCollect |
|
573 |
nil |
|
574 |
cleanupMemory |
|
575 |
nil |
|
576 |
compressSources |
|
577 |
). |
|
578 |
||
579 |
specialMenu := PopUpMenu |
|
580 |
labels:(resources array:labels) |
|
581 |
selectors:selectors. |
|
85 | 582 |
|
105 | 583 |
device ctrlDown ifTrue:[ |
323 | 584 |
^ specialMenu |
105 | 585 |
]. |
85 | 586 |
|
323 | 587 |
labels := #( |
588 |
'collect garbage' |
|
589 |
'collect garbage & symbols' |
|
590 |
'collect garbage & compress' |
|
591 |
'-' |
|
592 |
'background collect' |
|
593 |
'-' |
|
517 | 594 |
'reset statistic values' |
595 |
'-' |
|
323 | 596 |
'others' |
597 |
). |
|
598 |
||
599 |
selectors := #( |
|
600 |
garbageCollect |
|
601 |
garbageCollectAndSymbols |
|
602 |
compressingGarbageCollect |
|
603 |
nil |
|
604 |
backgroundCollect |
|
605 |
nil |
|
517 | 606 |
resetStatisticValues |
607 |
nil |
|
323 | 608 |
otherMenu |
609 |
). |
|
610 |
m := PopUpMenu labels:(resources array:labels) |
|
611 |
selectors:selectors. |
|
612 |
||
613 |
m subMenuAt:#otherMenu put:specialMenu. |
|
614 |
^ m |
|
85 | 615 |
! |
616 |
||
45 | 617 |
realize |
618 |
super realize. |
|
619 |
updateBlock notNil ifTrue:[ |
|
93 | 620 |
Processor addTimedBlock:updateBlock afterSeconds:updateInterval. |
45 | 621 |
] ifFalse:[ |
93 | 622 |
myProcess := [ |
623 |
|d| |
|
45 | 624 |
|
93 | 625 |
[true] whileTrue:[ |
626 |
(Delay forSeconds:updateInterval) wait. |
|
627 |
self updateDisplay |
|
628 |
] |
|
629 |
] forkAt:6. |
|
630 |
myProcess name:'monitor [' , |
|
631 |
Processor activeProcess id printString , |
|
632 |
'] update' |
|
45 | 633 |
]. |
634 |
||
635 |
newColor := newColor on:device. |
|
636 |
freeColor := freeColor on:device. |
|
637 |
oldColor := oldColor on:device. |
|
638 |
||
639 |
font := font on:device. |
|
640 |
! ! |
|
641 |
||
52 | 642 |
!MemoryMonitor methodsFor:'menu functions'! |
643 |
||
311 | 644 |
backgroundCollect |
645 |
"start a background (non disturbing) incremental GC. |
|
646 |
Since the GC is performed at a low priority, it may not make progress if higher |
|
647 |
prio processes are running" |
|
648 |
||
649 |
[ |
|
650 |
ObjectMemory incrementalGC |
|
651 |
] forkAt:5 |
|
652 |
! |
|
653 |
||
105 | 654 |
cleanupMemory |
655 |
"let all classes release unneeded, cached |
|
656 |
data ..." |
|
657 |
||
469
3653317928e2
dont repeat coding in ObjectMemory ...
Claus Gittinger <cg@exept.de>
parents:
360
diff
changeset
|
658 |
ObjectMemory performLowSpaceCleanup. |
3653317928e2
dont repeat coding in ObjectMemory ...
Claus Gittinger <cg@exept.de>
parents:
360
diff
changeset
|
659 |
|
105 | 660 |
" |
661 |
then, perform a GC (incl. symbol reclamation) |
|
662 |
" |
|
663 |
ObjectMemory reclaimSymbols. |
|
664 |
" |
|
665 |
finally, compress |
|
666 |
" |
|
667 |
ObjectMemory verboseGarbageCollect. |
|
668 |
! |
|
669 |
||
311 | 670 |
compressSources |
323 | 671 |
(self confirm:'This saves all in-memory source strings into a file |
360 | 672 |
and makes methods reference these (file-) strings, |
673 |
freeing all in-memory sources. |
|
323 | 674 |
|
675 |
If that source file is ever lost or gets out of sync with |
|
676 |
your system, those method sources are lost and the browser |
|
677 |
will show garbage. |
|
678 |
However, you still have a change file as backup. |
|
679 |
||
680 |
(Be especially careful, if you move images around: |
|
360 | 681 |
the source file must then be the correct one for that image) |
323 | 682 |
|
683 |
A compress is only useful, if you added many methods |
|
684 |
and the systems response time suffers from paging. |
|
685 |
||
686 |
Compress anyway ?') ifTrue:[ |
|
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
687 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
688 |
Smalltalk compressSources. |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
689 |
ObjectMemory markAndSweep |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
690 |
] |
323 | 691 |
] |
692 |
||
360 | 693 |
"Modified: 9.2.1996 / 18:17:22 / cg" |
311 | 694 |
! |
156 | 695 |
|
311 | 696 |
compressingGarbageCollect |
697 |
"perform a blocking compressing garbage collect." |
|
698 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
699 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
700 |
ObjectMemory verboseGarbageCollect |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
701 |
] |
156 | 702 |
! |
703 |
||
52 | 704 |
garbageCollect |
159 | 705 |
"perform a blocking (non compressing) garbage collect" |
706 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
707 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
708 |
ObjectMemory markAndSweep |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
709 |
] |
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 |
"Modified: 2.1.1996 / 12:17:33 / cg" |
52 | 712 |
! |
713 |
||
105 | 714 |
garbageCollectAndSymbols |
159 | 715 |
"perform a blocking (non compressing) garbage collect |
716 |
and reclaim unreferenced symbols." |
|
717 |
||
350
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
718 |
windowGroup withWaitCursorDo:[ |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
719 |
ObjectMemory reclaimSymbols |
68c5fed6c9bc
show waitCursor while collecting
Claus Gittinger <cg@exept.de>
parents:
323
diff
changeset
|
720 |
] |
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 |
"Modified: 2.1.1996 / 12:17:36 / cg" |
105 | 723 |
! |
724 |
||
311 | 725 |
incrementalCollect |
726 |
"start an incremental GC which does not disturb too much, but is guaranteed to |
|
727 |
make progress. |
|
323 | 728 |
This is done by doing the IGC at a very high priority, but giving up the CPU after |
729 |
every step. Due to the long delays, this may take a while to finish. |
|
730 |
Notice, that this is different from doing a background collect: that one |
|
731 |
may not make any progress if higher prio processes are runnable." |
|
732 |
||
733 |
|done delay| |
|
734 |
||
311 | 735 |
[ |
323 | 736 |
done := false. |
737 |
delay := Delay new. |
|
738 |
[done] whileFalse:[ |
|
739 |
10 timesRepeat:[ |
|
740 |
done ifFalse:[done := ObjectMemory gcStep]. |
|
741 |
]. |
|
742 |
(delay delay:10) wait |
|
743 |
] |
|
311 | 744 |
] forkAt:Processor highestPriority |
323 | 745 |
|
746 |
"Modified: 23.12.1995 / 17:31:55 / cg" |
|
311 | 747 |
! |
159 | 748 |
|
311 | 749 |
resetStatisticValues |
750 |
ObjectMemory resetMaxInterruptLatency. |
|
751 |
ObjectMemory resetMinScavengeReclamation. |
|
752 |
||
753 |
"Created: 7.11.1995 / 17:44:59 / cg" |
|
52 | 754 |
! |
755 |
||
105 | 756 |
scavenge |
159 | 757 |
"perform a blocking newspace garbage collect. |
758 |
(this is for debugging only - the system does this automatically)" |
|
759 |
||
105 | 760 |
ObjectMemory scavenge |
761 |
! |
|
762 |
||
763 |
tenure |
|
159 | 764 |
"empty the newSpace, by aging all new objects immediately and transfering them |
765 |
into oldSpace. |
|
766 |
(this is for debugging only - the system does this automatically)" |
|
767 |
||
105 | 768 |
ObjectMemory tenure |
311 | 769 |
! ! |
105 | 770 |
|
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
771 |
!MemoryMonitor class methodsFor:'documentation'! |
85 | 772 |
|
311 | 773 |
version |
696
b55f8705bb41
show memory use of dynamic code cache
Claus Gittinger <cg@exept.de>
parents:
517
diff
changeset
|
774 |
^ '$Header: /cvs/stx/stx/libtool/MemoryMonitor.st,v 1.36 1996-08-24 10:07:24 cg Exp $' |
52 | 775 |
! ! |