author | Claus Gittinger <cg@exept.de> |
Sat, 31 Jan 2015 13:51:50 +0100 | |
changeset 15133 | 3d069aea5d09 |
parent 14921 | eb71540a0256 |
child 15318 | 06e31ccd4966 |
permissions | -rw-r--r-- |
45 | 1 |
" |
2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
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 |
" |
|
2651 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
19 | 14 |
StandardSystemView subclass:#MemoryUsageView |
9887 | 15 |
instanceVariableNames:'rawInfo info list sortBlock titleLabel prevRawInfo |
9925 | 16 |
autoUpdateProcess autoUpdateInterval filter infoLabel' |
9929 | 17 |
classVariableNames:'LastSearchString' |
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
18 |
poolDictionaries:'' |
1053 | 19 |
category:'Monitors-ST/X' |
19 | 20 |
! |
21 |
||
9887 | 22 |
Object subclass:#StatisticEntry |
23 |
instanceVariableNames:'classNameOrSymbol overallByteSize minByteSize maxByteSize |
|
24 |
averageSize instanceCount instanceAllocationRate |
|
25 |
memoryAllocationRate' |
|
26 |
classVariableNames:'' |
|
27 |
poolDictionaries:'' |
|
28 |
privateIn:MemoryUsageView |
|
29 |
! |
|
30 |
||
769 | 31 |
!MemoryUsageView class methodsFor:'documentation'! |
19 | 32 |
|
45 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
36 |
All Rights Reserved |
|
19 | 37 |
|
45 | 38 |
This software is furnished under a license and may be used |
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
19 | 46 |
|
45 | 47 |
documentation |
48 |
" |
|
49 |
this view shows an overview over the memory usage of the system. |
|
50 |
usage: |
|
9887 | 51 |
MemoryUsageView new open |
19 | 52 |
|
45 | 53 |
Since scanning all memory takes some time, this is not done |
54 |
automatically, but upon request. See the middlebuttonmenu-'update' |
|
55 |
function. |
|
9887 | 56 |
|
57 |
This is a very old application - definitely needs some pimping to look better... |
|
58 |
... any maybe a nice menu, graphical display etc. |
|
45 | 59 |
" |
19 | 60 |
! ! |
61 |
||
1823 | 62 |
!MemoryUsageView class methodsFor:'startup'! |
63 |
||
64 |
isVisualStartable |
|
65 |
^ true |
|
66 |
||
67 |
"Created: / 10.8.1998 / 16:02:59 / cg" |
|
68 |
! ! |
|
69 |
||
9887 | 70 |
!MemoryUsageView methodsFor:'auto update'! |
71 |
||
72 |
autoUpdate |
|
73 |
self pushEvent:#update |
|
74 |
||
75 |
"Created: / 05-05-2011 / 17:20:52 / cg" |
|
76 |
! |
|
77 |
||
78 |
autoUpdateInterval |
|
79 |
^ autoUpdateInterval ? 30 seconds |
|
80 |
||
81 |
"Created: / 05-05-2011 / 17:20:49 / cg" |
|
82 |
! |
|
83 |
||
84 |
autoUpdateLoop |
|
85 |
[true] whileTrue:[ |
|
86 |
self autoUpdate. |
|
87 |
Delay waitFor:self autoUpdateInterval |
|
88 |
]. |
|
89 |
||
90 |
"Created: / 05-05-2011 / 17:20:44 / cg" |
|
91 |
! |
|
92 |
||
93 |
openAutoUpdateIntervalDialog |
|
94 |
|s| |
|
95 |
||
96 |
s := Dialog request:'Update interval [smh]:' initialAnswer:self autoUpdateInterval printString. |
|
97 |
s isEmptyOrNil ifTrue:[^ self]. |
|
98 |
||
99 |
autoUpdateInterval := TimeDuration readFrom:s. |
|
100 |
||
101 |
"Created: / 05-05-2011 / 17:24:48 / cg" |
|
102 |
! |
|
103 |
||
104 |
startAutoUpdateProcess |
|
105 |
autoUpdateProcess notNil ifTrue:[ |
|
106 |
self stopAutoUpdateProcess. |
|
107 |
]. |
|
108 |
autoUpdateProcess := |
|
109 |
[ |
|
110 |
self autoUpdateLoop |
|
111 |
] fork |
|
112 |
||
113 |
"Created: / 05-05-2011 / 17:19:00 / cg" |
|
114 |
! |
|
115 |
||
116 |
stopAutoUpdateProcess |
|
117 |
|p| |
|
118 |
||
119 |
(p := autoUpdateProcess) notNil ifTrue:[ |
|
120 |
autoUpdateProcess := nil. |
|
121 |
p terminate. |
|
122 |
]. |
|
123 |
||
124 |
"Created: / 05-05-2011 / 17:19:03 / cg" |
|
125 |
! ! |
|
126 |
||
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
127 |
!MemoryUsageView methodsFor:'initialization'! |
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
128 |
|
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
129 |
initialize |
1348 | 130 |
|helpView headLine| |
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
131 |
|
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
132 |
super initialize. |
4253 | 133 |
self label:'Memory Usage'. |
19 | 134 |
|
9887 | 135 |
headLine := ' Class' paddedTo:47 with:Character space. |
136 |
headLine := headLine , '# of Insts Bytes Avg sz Max sz %Mem %Accum. +Insts +Bytes'. |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
137 |
|
1348 | 138 |
titleLabel := Label in:self. |
9925 | 139 |
titleLabel origin:(0.0 @ 0.0) corner:(1.0 @ titleLabel preferredHeight). |
1348 | 140 |
titleLabel borderWidth:0. |
141 |
titleLabel label:headLine. |
|
142 |
titleLabel adjust:#left. |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
143 |
|
9925 | 144 |
infoLabel := Label in:self. |
145 |
infoLabel geometryLayout:(LayoutFrame |
|
146 |
leftFraction:0 offset:0 |
|
147 |
rightFraction:1.0 offset:0 |
|
148 |
topFraction:1.0 offset:infoLabel preferredHeight negated |
|
149 |
bottomFraction:1.0 offset:0). |
|
150 |
infoLabel borderWidth:0. |
|
151 |
infoLabel label:''. |
|
152 |
infoLabel adjust:#left. |
|
153 |
infoLabel level:-1. |
|
154 |
||
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
155 |
helpView := ScrollableView for:SelectionInListView in:self. |
9925 | 156 |
helpView geometryLayout:(LayoutFrame |
157 |
leftFraction:0 offset:0 |
|
158 |
rightFraction:1.0 offset:0 |
|
159 |
topFraction:0 offset:titleLabel height |
|
160 |
bottomFraction:1.0 offset:infoLabel height negated). |
|
92 | 161 |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
162 |
list := helpView scrolledView. |
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
163 |
|
1348 | 164 |
titleLabel origin:(list originRelativeTo:self) x @ 0.0. |
92 | 165 |
|
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
166 |
list font:(EditTextView defaultFont). |
1348 | 167 |
titleLabel font:(EditTextView defaultFont). |
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
168 |
list menuHolder:self; menuPerformer:self; menuMessage:#usageMenu. |
92 | 169 |
|
14921
eb71540a0256
Fix in MemoryUsageView - user self device instead of diretly accessing instvar,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14692
diff
changeset
|
170 |
self extent:((list font widthOf:headLine) + (self device horizontalPixelPerMillimeter * 15) rounded) @ self height. |
9887 | 171 |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
172 |
" |
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
173 |
MemoryUsageView open |
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
174 |
" |
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
175 |
|
9925 | 176 |
"Modified: / 08-05-2011 / 12:45:06 / cg" |
14921
eb71540a0256
Fix in MemoryUsageView - user self device instead of diretly accessing instvar,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14692
diff
changeset
|
177 |
"Modified: / 26-11-2014 / 16:00:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9887 | 178 |
! |
179 |
||
180 |
release |
|
181 |
self stopAutoUpdateProcess. |
|
182 |
super release. |
|
183 |
||
184 |
"Created: / 05-05-2011 / 17:26:24 / cg" |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
185 |
! ! |
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
186 |
|
9887 | 187 |
!MemoryUsageView methodsFor:'menu-actions'! |
19 | 188 |
|
9387 | 189 |
browseClass |
190 |
|class| |
|
191 |
||
192 |
list selection notNil ifTrue:[ |
|
9930 | 193 |
class := (info at:(list selection)) classNameOrSymbol. |
194 |
class isSymbol ifFalse:[ |
|
13021 | 195 |
UserPreferences systemBrowserClass openInClass:class. |
9930 | 196 |
] |
9387 | 197 |
] |
9930 | 198 |
|
199 |
"Modified: / 11-05-2011 / 14:34:38 / cg" |
|
9387 | 200 |
! |
201 |
||
1348 | 202 |
collectGarbageAndUpdate |
203 |
self withWaitCursorDo:[ |
|
1387
355fc1057e11
better print of java objects
Claus Gittinger <cg@exept.de>
parents:
1348
diff
changeset
|
204 |
ObjectMemory tenure. |
355fc1057e11
better print of java objects
Claus Gittinger <cg@exept.de>
parents:
1348
diff
changeset
|
205 |
ObjectMemory compressingGarbageCollect. |
1348 | 206 |
]. |
207 |
self update. |
|
208 |
||
209 |
"Created: 14.10.1997 / 21:36:38 / cg" |
|
210 |
"Modified: 14.10.1997 / 21:41:11 / cg" |
|
211 |
! |
|
212 |
||
1450 | 213 |
displayGlobalRefChainsToInsts |
214 |
|class| |
|
215 |
||
216 |
list selection notNil ifTrue:[ |
|
9930 | 217 |
class := (info at:(list selection)) classNameOrSymbol. |
1450 | 218 |
self withCursor:(Cursor questionMark) do:[ |
9936 | 219 |
|insts numInsts limit answer tooMany| |
1450 | 220 |
|
221 |
" |
|
222 |
special kludge |
|
223 |
" |
|
224 |
class isSymbol ifTrue:[ |
|
2653 | 225 |
class == #NameSpace ifFalse:[ |
1450 | 226 |
self information:'classes are directly refered to by Smalltalk'. |
227 |
^ self. |
|
228 |
]. |
|
229 |
class := (Smalltalk at:class) class. |
|
230 |
insts := class allSubInstances. |
|
231 |
insts remove:class soleInstance ifAbsent:nil |
|
232 |
] ifFalse:[ |
|
13757 | 233 |
tooMany := false. |
9936 | 234 |
Error handle:[:ex | |
235 |
tooMany := true. |
|
236 |
] do:[ |
|
237 |
insts := class allInstances. |
|
238 |
numInsts := insts size |
|
239 |
]. |
|
240 |
tooMany ifTrue:[ |
|
241 |
numInsts := class instanceCount. |
|
242 |
]. |
|
1450 | 243 |
]. |
9936 | 244 |
numInsts > 10 ifTrue:[ |
9339
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
245 |
answer := Dialog |
9936 | 246 |
request:('There are ' , numInsts printString , ' instances.\Do you really want to follow them all ?\\(Give number to follow or cancel)' withCRs) |
247 |
initialAnswer:(numInsts min:10) printString. |
|
9339
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
248 |
|
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
249 |
limit := Integer readFrom:answer onError:nil. |
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
250 |
limit isNil ifTrue:[^ self]. |
9936 | 251 |
insts isNil ifTrue:[ |
252 |
[:exit | |
|
253 |
insts := OrderedCollection new. |
|
254 |
class allInstancesDo:[:inst | |
|
255 |
insts add:inst. |
|
256 |
insts size == limit ifTrue:[ exit value:nil ]. |
|
257 |
] |
|
258 |
] valueWithExit. |
|
259 |
] ifFalse:[ |
|
260 |
insts := (insts asArray copyTo:limit) |
|
261 |
] |
|
1450 | 262 |
]. |
263 |
insts := insts asArray. |
|
9340
5c9f76236b92
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
9339
diff
changeset
|
264 |
ObjectMemory displayRefChainToAny:insts limitNumberOfSearchedReferences:(limit ? 1000). |
1450 | 265 |
] |
266 |
] |
|
267 |
||
9930 | 268 |
"Created: / 03-02-1998 / 00:03:22 / cg" |
269 |
"Modified: / 11-05-2011 / 14:33:04 / cg" |
|
9936 | 270 |
"Modified: / 16-06-2011 / 16:14:40 / az" |
1450 | 271 |
! |
272 |
||
45 | 273 |
inspectInstances |
9930 | 274 |
self withCursor:(Cursor questionMark) do:[ |
275 |
self withInstancesOfSelectedClassDo:[:insts | |
|
9936 | 276 |
|answer| |
277 |
||
278 |
answer := true. |
|
2697
b4f4e431b71e
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
2653
diff
changeset
|
279 |
insts size > 500 ifTrue:[ |
9936 | 280 |
answer := OptionBox |
281 |
request:('there are ' , insts size printString , ' instances.\\Do you really want to see them all ?' withCRs) |
|
282 |
buttonLabels:#('Yes' 'Show me any 500' 'No' ) |
|
283 |
values:#(true #some false) |
|
284 |
default:true. |
|
2697
b4f4e431b71e
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
2653
diff
changeset
|
285 |
]. |
9936 | 286 |
answer ~~ false ifTrue:[ |
287 |
answer == #some ifTrue:[ |
|
288 |
(insts copyTo:500) inspect. |
|
289 |
] ifFalse:[ |
|
290 |
insts inspect |
|
291 |
] |
|
292 |
]. |
|
2697
b4f4e431b71e
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
2653
diff
changeset
|
293 |
] |
52 | 294 |
] |
770 | 295 |
|
9930 | 296 |
"Modified: / 11-05-2011 / 14:36:44 / cg" |
9936 | 297 |
"Modified: / 16-06-2011 / 15:57:52 / az" |
52 | 298 |
! |
299 |
||
1738 | 300 |
inspectInstancesWithSearch |
9930 | 301 |
|filterString filterBlock| |
302 |
||
303 |
list selection isNil ifTrue:[^ self]. |
|
1738 | 304 |
|
9929 | 305 |
filterString := LastSearchString ? '[:inst | "<some condition for inst>" ]'. |
1738 | 306 |
[filterBlock isNil] whileTrue:[ |
9929 | 307 |
filterString := Dialog request:'filter block:' initialAnswer:filterString. |
308 |
filterString size == 0 ifTrue:[^ self]. |
|
1738 | 309 |
|
9929 | 310 |
filterBlock := Compiler evaluate:filterString. |
1738 | 311 |
filterBlock isBlock ifFalse:[ |
312 |
self information:'bad syntax in block'. |
|
313 |
filterBlock := nil. |
|
314 |
]. |
|
315 |
]. |
|
316 |
||
9929 | 317 |
LastSearchString := filterString. |
318 |
||
9930 | 319 |
self withCursor:(Cursor questionMark) do:[ |
320 |
self withInstancesOfSelectedClassDo:[:insts | |
|
321 |
|filteredInsts| |
|
1738 | 322 |
|
9930 | 323 |
filteredInsts := insts select:filterBlock. |
324 |
filteredInsts size > 500 ifTrue:[ |
|
325 |
(self confirm:'there are ' , filteredInsts size printString , ' instances.\\Do you really want to see them all ?' withCRs) |
|
1738 | 326 |
ifFalse:[^ self] |
327 |
]. |
|
9930 | 328 |
filteredInsts inspect |
1738 | 329 |
] |
330 |
] |
|
331 |
||
9930 | 332 |
"Modified: / 11-05-2011 / 14:38:12 / cg" |
1738 | 333 |
! |
334 |
||
12030 | 335 |
inspectLargestInstances |
336 |
|tenBiggest smallestOfThe10| |
|
337 |
||
338 |
tenBiggest := SortedCollection new:20. |
|
339 |
tenBiggest sortBlock:[:a :b | a size > b size]. |
|
340 |
smallestOfThe10 := nil. |
|
341 |
||
342 |
self withCursor:(Cursor questionMark) do:[ |
|
343 |
self withInstancesOfSelectedClassDo:[:insts | |
|
344 |
insts do:[:each | |
|
345 |
smallestOfThe10 isNil ifTrue:[ |
|
346 |
smallestOfThe10 := each size. |
|
347 |
tenBiggest add:each. |
|
348 |
] ifFalse:[ |
|
349 |
each basicSize > smallestOfThe10 ifTrue:[ |
|
350 |
tenBiggest add:each. |
|
351 |
tenBiggest size > 10 ifTrue:[ |
|
352 |
tenBiggest removeLast. |
|
353 |
smallestOfThe10 := tenBiggest last size. |
|
354 |
] |
|
355 |
] |
|
356 |
]. |
|
357 |
]. |
|
358 |
tenBiggest inspect |
|
359 |
] |
|
360 |
] |
|
361 |
||
362 |
"Modified: / 11-05-2011 / 14:36:44 / cg" |
|
363 |
"Modified: / 16-06-2011 / 15:57:52 / az" |
|
364 |
! |
|
365 |
||
52 | 366 |
inspectOwners |
69 | 367 |
|class inspector| |
52 | 368 |
|
9930 | 369 |
list selection isNil ifTrue:[^ self]. |
770 | 370 |
|
9930 | 371 |
class := (info at:(list selection)) classNameOrSymbol. |
372 |
" |
|
373 |
special kludge |
|
374 |
" |
|
375 |
class isSymbol ifTrue:[^self]. |
|
376 |
||
377 |
self withCursor:(Cursor questionMark) do:[ |
|
378 |
|owners dict| |
|
52 | 379 |
|
9930 | 380 |
owners := (ObjectMemory whoReferencesInstancesOf:class). |
381 |
owners isEmptyOrNil ifTrue:[ |
|
382 |
self information:'No owners found - next GC should remove it'. |
|
383 |
^ self |
|
384 |
]. |
|
385 |
owners := owners asOrderedCollection. |
|
386 |
owners size > 500 ifTrue:[ |
|
387 |
(self confirm:'there are ' , owners size printString , ' owners.\\Do you really want to see them all ?' withCRs) |
|
388 |
ifFalse:[^ self] |
|
389 |
]. |
|
390 |
dict := IdentityDictionary new. |
|
391 |
owners do:[:owner | |
|
392 |
|set names oClass s nMore| |
|
52 | 393 |
|
9930 | 394 |
" |
395 |
skip weakArrays ... (they dont count) |
|
396 |
" |
|
397 |
(owner isMemberOf:WeakArray) ifFalse:[ |
|
398 |
nMore := nil. |
|
399 |
set := Set new. |
|
400 |
owner == Smalltalk ifTrue:[ |
|
401 |
owner keysAndValuesDo:[:key :val | |
|
402 |
(val isMemberOf:class) ifTrue:[ |
|
403 |
set add:key |
|
7918 | 404 |
] |
9930 | 405 |
] |
406 |
] ifFalse:[ |
|
407 |
names := owner class allInstVarNames. |
|
408 |
oClass := owner class. |
|
409 |
1 to:oClass instSize do:[:i | |
|
410 |
((owner instVarAt:i) isMemberOf:class) ifTrue:[ |
|
411 |
set add:(names at:i). |
|
7918 | 412 |
]. |
9930 | 413 |
]. |
414 |
oClass isVariable ifTrue:[ |
|
415 |
oClass isPointers ifTrue:[ |
|
416 |
1 to:owner basicSize do:[:i | |
|
417 |
((owner basicAt:i) isMemberOf:class) ifTrue:[ |
|
418 |
nMore isNil ifTrue:[ |
|
419 |
set add:i. |
|
420 |
set size > 500 ifTrue:[ |
|
421 |
nMore := 0. |
|
7950 | 422 |
] |
9930 | 423 |
] ifFalse:[ |
424 |
nMore := nMore + 1. |
|
7918 | 425 |
] |
426 |
] |
|
427 |
] |
|
9930 | 428 |
] |
7918 | 429 |
]. |
9930 | 430 |
]. |
431 |
" |
|
432 |
put a describing string into the dictionary |
|
433 |
" |
|
434 |
s := WriteStream on:String new. |
|
435 |
s nextPutAll:'references in: '. |
|
436 |
set do:[:name | |
|
437 |
name isString ifTrue:[ |
|
438 |
s nextPutAll:name; nextPutAll:' ' |
|
439 |
] ifFalse:[ |
|
440 |
s nextPutAll:'['; nextPutAll:name printString; nextPutAll:'] ' |
|
441 |
] |
|
442 |
]. |
|
443 |
nMore notNil ifTrue:[ |
|
444 |
s nextPutAll:'... (', nMore printString,' more)' |
|
445 |
]. |
|
446 |
dict at:owner put:(s contents). |
|
57 | 447 |
"/ dict at:owner put:set |
9930 | 448 |
] |
449 |
]. |
|
450 |
inspector := DictionaryInspectorView openOn:dict. |
|
451 |
inspector listView doubleClickAction:[:lineNr | inspector doInspectKey]. |
|
45 | 452 |
] |
770 | 453 |
|
9930 | 454 |
"Modified: / 11-05-2011 / 14:39:30 / cg" |
45 | 455 |
! |
456 |
||
2858 | 457 |
nilInstances |
458 |
|class| |
|
459 |
||
9930 | 460 |
list selection isNil ifTrue:[^ self]. |
461 |
||
462 |
class := (info at:(list selection)) classNameOrSymbol. |
|
463 |
" |
|
464 |
special kludge |
|
465 |
" |
|
466 |
class isSymbol ifTrue:[^ self]. |
|
2858 | 467 |
|
9930 | 468 |
self withCursor:(Cursor questionMark) do:[ |
469 |
|insts| |
|
470 |
||
471 |
insts := class allInstances. |
|
472 |
insts notEmpty ifTrue:[ |
|
473 |
(self confirm:'there are ' , insts size printString , ' instances.\\Do you really want to nil them all ?' withCRs) |
|
474 |
ifTrue:[ |
|
475 |
insts do:[:each | |
|
476 |
each becomeNil |
|
2858 | 477 |
] |
9930 | 478 |
] |
479 |
]. |
|
2858 | 480 |
] |
481 |
||
9930 | 482 |
"Modified: / 11-05-2011 / 14:39:33 / cg" |
2858 | 483 |
! |
484 |
||
13346 | 485 |
openInheritanceFilterDialog |
486 |
"only show instances which inherit from a set of classes" |
|
487 |
||
488 |
|names classes classToCheck| |
|
489 |
||
490 |
names := Dialog requestClassName:'Filter Instances by Inheritance:' initialAnswer:''. |
|
491 |
names isEmptyOrNil ifTrue:[^ self]. |
|
9924 | 492 |
|
13346 | 493 |
classes := (names asCollectionOfSubstringsSeparatedByAny:' ;,') |
494 |
collect:[:each | Smalltalk classNamed:each ] |
|
495 |
thenSelect:[:cls |cls notNil]. |
|
496 |
classes isEmpty ifTrue:[^ self]. |
|
9924 | 497 |
|
13346 | 498 |
classes size == 1 ifTrue:[ |
499 |
classToCheck := classes first. |
|
500 |
filter := [:inst :class | class includesBehavior:classToCheck ]. |
|
501 |
] ifFalse:[ |
|
502 |
classes := classes asArray. |
|
503 |
filter := [:inst :class | classes contains:[:cls | class includesBehavior:cls]]. |
|
504 |
]. |
|
9924 | 505 |
prevRawInfo := nil. |
9925 | 506 |
self update. |
507 |
||
13346 | 508 |
infoLabel label:'Filtered by Inheritance: ',names. |
509 |
||
510 |
"Created: / 08-05-2011 / 12:18:21 / cg" |
|
511 |
! |
|
512 |
||
513 |
openNamespaceFilterDialog |
|
514 |
"only show instances for classes from a number of namespaces" |
|
515 |
||
516 |
|names nameSpaces ns| |
|
517 |
||
518 |
names := Dialog requestNameSpace:'Filter Instances by Namespace:' initialAnswer:''. |
|
519 |
names isEmptyOrNil ifTrue:[^ self]. |
|
520 |
||
521 |
nameSpaces := (names asCollectionOfSubstringsSeparatedByAny:' ;,') |
|
522 |
collect:[:each | Smalltalk classNamed:each ] |
|
523 |
thenSelect:[:cls | cls notNil]. |
|
524 |
nameSpaces isEmpty ifTrue:[^ self]. |
|
525 |
||
526 |
nameSpaces size == 1 ifTrue:[ |
|
527 |
ns := nameSpaces first. |
|
528 |
filter := [:inst :class | class topNameSpace == ns ]. |
|
529 |
] ifFalse:[ |
|
530 |
nameSpaces := nameSpaces asArray. |
|
531 |
filter := [:inst :class | nameSpaces includesIdentical:(class topNameSpace) ]. |
|
532 |
]. |
|
533 |
||
534 |
prevRawInfo := nil. |
|
535 |
self update. |
|
536 |
||
537 |
infoLabel label:'Filtered by Namespace: ',names. |
|
9924 | 538 |
|
539 |
"Created: / 08-05-2011 / 12:18:21 / cg" |
|
540 |
! |
|
541 |
||
542 |
removeFilter |
|
543 |
filter := nil. |
|
544 |
prevRawInfo := nil. |
|
9925 | 545 |
self update. |
546 |
||
547 |
infoLabel label:'No Filter.'. |
|
9924 | 548 |
|
549 |
"Created: / 08-05-2011 / 12:16:43 / cg" |
|
550 |
! |
|
551 |
||
19 | 552 |
update |
553 |
self updateInfo. |
|
554 |
self updateDisplay |
|
92 | 555 |
! |
45 | 556 |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
557 |
usageMenu |
1619
6e4b1930841a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1617
diff
changeset
|
558 |
<resource: #programMenu> |
6e4b1930841a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1617
diff
changeset
|
559 |
|
1348 | 560 |
|m| |
561 |
||
562 |
m := PopUpMenu |
|
1617
2403cee7dc5a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
563 |
itemList:#( |
9924 | 564 |
('Filter by Namespace...' openNamespaceFilterDialog ) |
13346 | 565 |
('Filter by Inheritance...' openInheritanceFilterDialog ) |
9924 | 566 |
('No Filter' removeFilter ) |
567 |
('-') |
|
4253 | 568 |
('Sort by Class Name' sortByClass ) |
569 |
('Sort by Classes Basename' sortByClassNameWithoutPrefix ) |
|
570 |
('Sort by Inst Count' sortByInstCount ) |
|
571 |
('Sort by Memory Usage' sortByMemoryUsage ) |
|
572 |
('Sort by Average Size' sortByAverageSize ) |
|
573 |
('Sort by Maximum Size' sortByMaxSize ) |
|
9887 | 574 |
('Sort by Inst Allocation Rate' sortByInstanceAllocationRate ) |
575 |
('Sort by Byte Allocation Rate' sortByMemoryAllocationRate ) |
|
1617
2403cee7dc5a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
576 |
('-') |
4253 | 577 |
('Inspect Instances' inspectInstances ) |
12030 | 578 |
('Inspect Largest Instances' inspectLargestInstances ) |
4253 | 579 |
('Inspect with Search' inspectInstancesWithSearch ) |
580 |
('Inspect Owners' inspectOwners ) |
|
9887 | 581 |
('-') |
4253 | 582 |
('Ref Chains' displayGlobalRefChainsToInsts ) |
583 |
('Clear (nil) Instances' nilInstances ) |
|
1617
2403cee7dc5a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
584 |
('-') |
9887 | 585 |
('Browse Class' browseClass ) |
9387 | 586 |
('-') |
9924 | 587 |
('Collect Garbage & Update' collectGarbageAndUpdate ) |
9887 | 588 |
('Start Autoupdate' startAutoUpdateProcess ) |
9924 | 589 |
('Autoupdate Interval...' openAutoUpdateIntervalDialog ) |
590 |
('Update' update ) |
|
1617
2403cee7dc5a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
591 |
) |
2403cee7dc5a
use new itemList message from PopUpMenu
Claus Gittinger <cg@exept.de>
parents:
1513
diff
changeset
|
592 |
resources:resources. |
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
593 |
|
9887 | 594 |
(list hasSelection not or:[list selection < 3]) ifTrue:[ |
1741 | 595 |
m disableAll:#(inspectInstances inspectInstancesWithSearch |
596 |
inspectOwners |
|
9887 | 597 |
displayGlobalRefChainsToInsts |
598 |
nilInstances browseClass). |
|
1348 | 599 |
]. |
9887 | 600 |
autoUpdateProcess notNil ifTrue:[ |
9925 | 601 |
m labelAt:#startAutoUpdateProcess put:'Stop Autoupdate'. |
602 |
m selectorAt:#startAutoUpdateProcess put:#stopAutoUpdateProcess |
|
9887 | 603 |
]. |
604 |
||
9924 | 605 |
filter isNil ifTrue:[ |
606 |
m disableAll:#(removeFilter) |
|
607 |
]. |
|
1348 | 608 |
^ m |
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
609 |
|
9925 | 610 |
"Modified: / 08-05-2011 / 12:38:47 / cg" |
9930 | 611 |
! |
612 |
||
613 |
withInstancesOfSelectedClassDo:aBlock |
|
614 |
|class insts| |
|
615 |
||
616 |
list selection isNil ifTrue:[ ^ self ]. |
|
617 |
||
618 |
class := (info at:(list selection)) classNameOrSymbol. |
|
619 |
||
620 |
" |
|
621 |
special kludge |
|
622 |
" |
|
623 |
class isSymbol ifTrue:[ |
|
9931 | 624 |
class == #NameSpace ifTrue:[ |
625 |
class := (Smalltalk at:class) class. |
|
626 |
insts := class allSubInstances. |
|
627 |
insts remove:class soleInstance ifAbsent:nil |
|
628 |
] ifFalse:[ |
|
629 |
class == #Metaclass ifTrue:[ |
|
630 |
insts := Metaclass allSubInstances. |
|
631 |
] ifFalse:[ |
|
632 |
class == #Class ifTrue:[ |
|
633 |
insts := Class allSubInstances. |
|
634 |
] ifFalse:[ |
|
635 |
^ self. |
|
636 |
]. |
|
637 |
] |
|
9930 | 638 |
]. |
639 |
] ifFalse:[ |
|
640 |
insts := class allInstances. |
|
641 |
]. |
|
642 |
aBlock value:insts |
|
643 |
||
644 |
"Created: / 11-05-2011 / 14:36:00 / cg" |
|
9887 | 645 |
! ! |
646 |
||
647 |
!MemoryUsageView methodsFor:'menu-sorting'! |
|
648 |
||
649 |
sortByAverageSize |
|
650 |
self label:'Memory usage; by average size'. |
|
651 |
||
652 |
sortBlock := [:a :b | |
|
653 |
|n1 n2 m1 m2| |
|
654 |
||
655 |
n1 := a averageSize. |
|
656 |
n2 := b averageSize. |
|
657 |
n1 > n2 |
|
658 |
or:[n1 == n2 |
|
659 |
and:[a classNameOrSymbol displayString < b classNameOrSymbol displayString]] |
|
660 |
]. |
|
661 |
self updateDisplay |
|
662 |
||
663 |
"Modified: / 05-05-2011 / 16:11:24 / cg" |
|
664 |
! |
|
665 |
||
666 |
sortByClass |
|
667 |
self label:'Memory usage; by class'. |
|
668 |
||
669 |
sortBlock := [:a :b | |
|
670 |
|c1 c2 s1 s2| |
|
671 |
||
672 |
c1 := a classNameOrSymbol. |
|
673 |
c2 := b classNameOrSymbol. |
|
674 |
||
675 |
s1 := c1 isBehavior ifTrue:[ c1 name] ifFalse:[ c1 displayString ]. |
|
676 |
s2 := c2 isBehavior ifTrue:[ c2 name ] ifFalse:[ c2 displayString ]. |
|
677 |
s1 < s2 |
|
678 |
]. |
|
679 |
self updateDisplay |
|
680 |
||
681 |
"Modified: / 05-05-2011 / 16:11:53 / cg" |
|
682 |
! |
|
683 |
||
684 |
sortByClassNameWithoutPrefix |
|
685 |
self label:'Memory usage; by className without prefix'. |
|
686 |
||
687 |
sortBlock := [:a :b | |
|
688 |
|c1 c2 s1 s2| |
|
689 |
||
690 |
c1 := a classNameOrSymbol. |
|
691 |
c2 := b classNameOrSymbol. |
|
692 |
||
693 |
s1 := c1 isBehavior ifTrue:[ c1 nameWithoutPrefix ] ifFalse:[ c1 displayString ]. |
|
694 |
s2 := c2 isBehavior ifTrue:[ c2 nameWithoutPrefix ] ifFalse:[ c2 displayString ]. |
|
695 |
s1 < s2 |
|
696 |
]. |
|
697 |
self updateDisplay |
|
698 |
||
699 |
"Modified: / 05-05-2011 / 16:12:10 / cg" |
|
700 |
! |
|
701 |
||
702 |
sortByInstCount |
|
703 |
self label:'Memory usage; by instance count'. |
|
704 |
||
705 |
sortBlock := [:a :b | |
|
706 |
|n1 n2| |
|
707 |
n1 := a instanceCount. |
|
708 |
n2 := b instanceCount. |
|
709 |
n1 > n2 |
|
710 |
or:[n1 == n2 |
|
711 |
and:[(a classNameOrSymbol) displayString < (b classNameOrSymbol) displayString]] |
|
712 |
]. |
|
713 |
self updateDisplay |
|
714 |
||
715 |
"Modified: / 05-05-2011 / 16:47:26 / cg" |
|
716 |
! |
|
717 |
||
718 |
sortByInstanceAllocationRate |
|
719 |
self label:'Memory usage; by inst allocation rate'. |
|
720 |
||
721 |
sortBlock := [:a :b | |
|
722 |
|n1 n2 m1 m2| |
|
723 |
||
724 |
n1 := a instanceAllocationRate. |
|
725 |
n2 := b instanceAllocationRate. |
|
726 |
n1 > n2 |
|
727 |
or:[n1 == n2 |
|
728 |
and:[a classNameOrSymbol displayString < b classNameOrSymbol displayString]] |
|
729 |
]. |
|
730 |
self updateDisplay |
|
731 |
||
732 |
"Created: / 05-05-2011 / 16:14:56 / cg" |
|
733 |
! |
|
734 |
||
735 |
sortByMaxSize |
|
736 |
self label:'Memory usage; by maximum size'. |
|
737 |
||
738 |
sortBlock := [:a :b | |
|
739 |
|n1 n2 m1 m2| |
|
740 |
||
741 |
n1 := a maxByteSize. |
|
742 |
n2 := b maxByteSize. |
|
743 |
n1 > n2 |
|
744 |
or:[n1 == n2 |
|
745 |
and:[(a classNameOrSymbol) displayString < (b classNameOrSymbol) displayString]] |
|
746 |
]. |
|
747 |
self updateDisplay |
|
748 |
||
749 |
"Modified: / 05-05-2011 / 16:13:20 / cg" |
|
750 |
! |
|
751 |
||
752 |
sortByMemoryAllocationRate |
|
753 |
self label:'Memory usage; by inst allocation rate'. |
|
754 |
||
755 |
sortBlock := [:a :b | |
|
756 |
|n1 n2 m1 m2| |
|
757 |
||
758 |
n1 := a memoryAllocationRate. |
|
759 |
n2 := b memoryAllocationRate. |
|
760 |
n1 > n2 |
|
761 |
or:[n1 == n2 |
|
762 |
and:[a classNameOrSymbol displayString < b classNameOrSymbol displayString]] |
|
763 |
]. |
|
764 |
self updateDisplay |
|
765 |
||
766 |
"Created: / 05-05-2011 / 16:15:17 / cg" |
|
767 |
! |
|
768 |
||
769 |
sortByMemoryUsage |
|
770 |
self label:'Memory usage; by memory usage'. |
|
771 |
||
772 |
sortBlock := [:a :b | |
|
773 |
|n1 n2| |
|
774 |
||
775 |
n1 := a overallByteSize. |
|
776 |
n2 := b overallByteSize. |
|
777 |
n1 > n2 |
|
778 |
or:[n1 == n2 |
|
779 |
and:[(a classNameOrSymbol) displayString < (b classNameOrSymbol) displayString]] |
|
780 |
]. |
|
781 |
self updateDisplay |
|
782 |
||
783 |
"Modified: / 05-05-2011 / 16:13:58 / cg" |
|
45 | 784 |
! ! |
785 |
||
19 | 786 |
!MemoryUsageView methodsFor:'private'! |
787 |
||
45 | 788 |
updateDisplay |
789 |
"update the displayed list" |
|
19 | 790 |
|
9887 | 791 |
|nameLen countLen bytesUsedSize avgSizeLen maxSizeLen accumMemoryUseLen| |
792 |
||
12892 | 793 |
rawInfo isNil ifTrue:[^ self]. |
794 |
||
9887 | 795 |
nameLen := 50. |
796 |
countLen := 7. |
|
797 |
bytesUsedSize := 10. |
|
798 |
avgSizeLen := 10. |
|
799 |
maxSizeLen := 8. |
|
800 |
accumMemoryUseLen := 7. |
|
801 |
||
49 | 802 |
windowGroup withCursor:Cursor wait do:[ |
1513 | 803 |
|classNames counts sumSizes maxSizes percents avgSizes |
804 |
l line allMemory |
|
805 |
overAllCount overAllAvgSize overAllMaxSize |
|
806 |
lastP sumPercent| |
|
49 | 807 |
|
9887 | 808 |
prevRawInfo notNil ifTrue:[ |
809 |
rawInfo keysAndValuesDo:[:key :entry | |
|
810 |
|prevEntry deltaInstCount deltaInstBytes prevInstCount prevInstBytes| |
|
811 |
||
812 |
prevEntry := prevRawInfo at:key ifAbsent:nil. |
|
813 |
prevInstCount := prevEntry notNil ifTrue:[prevEntry instanceCount] ifFalse:[0]. |
|
814 |
prevInstBytes := prevEntry notNil ifTrue:[prevEntry overallByteSize] ifFalse:0. |
|
815 |
deltaInstCount := entry instanceCount - prevInstCount. |
|
816 |
deltaInstBytes := entry overallByteSize - prevInstBytes. |
|
817 |
||
818 |
entry instanceAllocationRate:deltaInstCount. |
|
819 |
entry memoryAllocationRate:deltaInstBytes. |
|
820 |
]. |
|
821 |
]. |
|
822 |
||
9931 | 823 |
info := (OrderedCollection withAll:rawInfo) sort:sortBlock. |
19 | 824 |
|
9887 | 825 |
sumSizes := info collect:[:infoEntry | infoEntry overallByteSize ]. |
826 |
allMemory := sumSizes sum. |
|
1513 | 827 |
percents := sumSizes collect:[:sz | (sz asFloat / allMemory * 100)]. |
828 |
sumPercent := 0. |
|
52 | 829 |
|
9887 | 830 |
overAllMaxSize := overAllCount := 0. |
831 |
||
1513 | 832 |
l := OrderedCollection new. |
9887 | 833 |
info doWithIndex:[:entry :i | |
12889 | 834 |
|line avgSz avgSzString maxSz instCount percent allocRate memRate s1 s2| |
19 | 835 |
|
9887 | 836 |
maxSz := entry maxByteSize. |
837 |
avgSz := entry averageSize asFixedPoint:1. |
|
1513 | 838 |
avgSz = maxSz ifTrue:[ |
9887 | 839 |
avgSzString := avgSz asInteger printString , ' '. |
840 |
] ifFalse:[ |
|
841 |
avgSzString := avgSz printString. |
|
1513 | 842 |
]. |
9887 | 843 |
instCount := entry instanceCount. |
844 |
||
845 |
line := entry classNameStringInList printStringPaddedTo:nameLen. |
|
846 |
line := line contractTo:nameLen. |
|
847 |
||
848 |
line := line , (instCount printStringLeftPaddedTo:countLen). |
|
849 |
line := line , (entry overallByteSize printStringLeftPaddedTo:bytesUsedSize). |
|
850 |
line := line , (avgSzString leftPaddedTo:avgSizeLen). |
|
851 |
line := line , (maxSz printStringLeftPaddedTo:maxSizeLen). |
|
1513 | 852 |
percent := (percents at:i). |
1348 | 853 |
"/ percent < 0.0 ifTrue:[self halt]. |
9887 | 854 |
line := line , ((percent asFixedPoint:1) printStringLeftPaddedTo:accumMemoryUseLen). |
1513 | 855 |
lastP := sumPercent := ((sumPercent + percent) min:100.0). |
9887 | 856 |
line := line , ((sumPercent asFixedPoint:1) printStringLeftPaddedTo:accumMemoryUseLen). |
857 |
||
12889 | 858 |
allocRate := entry instanceAllocationRate. |
859 |
memRate := entry memoryAllocationRate. |
|
860 |
s1 := allocRate printString. |
|
861 |
s2 := memRate printString. |
|
862 |
allocRate > 0 ifTrue:[ |
|
863 |
s1 := s1 colorizeAllWith:(Color red). |
|
864 |
s2 := s2 colorizeAllWith:(Color red). |
|
865 |
] ifFalse:[ |
|
866 |
allocRate < 0 ifTrue:[ |
|
867 |
s1 := s1 colorizeAllWith:(Color green darkened). |
|
868 |
s2 := s2 colorizeAllWith:(Color green darkened). |
|
869 |
] |
|
870 |
]. |
|
871 |
line := line , (s1 leftPaddedTo:countLen). |
|
872 |
line := line , (s2 leftPaddedTo:bytesUsedSize). |
|
9887 | 873 |
|
874 |
l add:line. |
|
875 |
||
876 |
overAllMaxSize := overAllMaxSize max:entry maxByteSize. |
|
877 |
overAllCount := overAllCount + instCount. |
|
1513 | 878 |
]. |
1348 | 879 |
"/ (((lastP asFixedPoint:1) printStringLeftPaddedTo:7) startsWith:'99.') ifTrue:[self halt]. |
1513 | 880 |
"add summary line" |
14692 | 881 |
overAllAvgSize := 0. |
882 |
overAllCount == 0 ifFalse:[ |
|
883 |
overAllAvgSize := ((allMemory / overAllCount) * 10) rounded / 10.0. |
|
884 |
]. |
|
19 | 885 |
|
9887 | 886 |
l addFirst:''. |
887 |
line := 'all objects' printStringPaddedTo:nameLen. |
|
888 |
line := line , (overAllCount printStringLeftPaddedTo:countLen). |
|
889 |
line := line , (allMemory printStringLeftPaddedTo:bytesUsedSize). |
|
890 |
line := line , (overAllAvgSize printStringLeftPaddedTo:avgSizeLen). |
|
891 |
line := line , (overAllMaxSize printStringLeftPaddedTo:maxSizeLen). |
|
892 |
line := line , (100.0 printStringLeftPaddedTo:accumMemoryUseLen). |
|
893 |
l addFirst:line. |
|
92 | 894 |
|
9931 | 895 |
info addFirst:nil; addFirst:nil. |
896 |
||
1513 | 897 |
list list:l. |
49 | 898 |
] |
142 | 899 |
|
9887 | 900 |
"Created: / 19-09-1995 / 15:30:47 / claus" |
9931 | 901 |
"Modified: / 11-05-2011 / 14:47:52 / cg" |
45 | 902 |
! |
19 | 903 |
|
45 | 904 |
updateInfo |
905 |
"scan all memory and collect the information" |
|
906 |
||
49 | 907 |
windowGroup withCursor:Cursor questionMark do:[ |
2651 | 908 |
|myProcess myPriority| |
45 | 909 |
|
2651 | 910 |
"find all objects, collect stuff in info" |
45 | 911 |
|
2651 | 912 |
" |
913 |
this is a time consuming operation; therefore lower my priority ... |
|
914 |
" |
|
915 |
myProcess := Processor activeProcess. |
|
916 |
myPriority := myProcess priority. |
|
917 |
myProcess priority:(Processor userBackgroundPriority). |
|
9887 | 918 |
prevRawInfo := rawInfo. |
45 | 919 |
|
2651 | 920 |
rawInfo := IdentityDictionary new:600. |
52 | 921 |
|
2651 | 922 |
[ |behaviorFlag| |
142 | 923 |
|
2651 | 924 |
behaviorFlag := Behavior flagBehavior. |
142 | 925 |
|
2651 | 926 |
ObjectMemory allObjectsDo:[:o | |
9924 | 927 |
|infoEntry class flags skip| |
928 |
||
929 |
skip := false. |
|
45 | 930 |
|
142 | 931 |
"/ o isBehavior ifTrue:[ |
2651 | 932 |
class := o class. |
7860 | 933 |
flags := class flags. |
934 |
(flags notNil and:[flags class == SmallInteger]) ifTrue:[ |
|
9924 | 935 |
(filter isNil or:[ filter value:o value:class ]) ifTrue:[ |
936 |
(flags bitAnd:behaviorFlag) ~~ 0 ifTrue:[ |
|
937 |
Error |
|
938 |
handle:[:ex |] |
|
939 |
do:[ |
|
940 |
o isObsolete ifTrue:[ |
|
941 |
class := #ObsoleteClass |
|
942 |
] ifFalse:[ |
|
943 |
o isMeta ifTrue:[ |
|
944 |
o isPrivate ifTrue:[ |
|
945 |
class := #PrivateMetaclass |
|
946 |
] ifFalse:[ |
|
947 |
class := #Metaclass |
|
948 |
] |
|
7860 | 949 |
] ifFalse:[ |
9924 | 950 |
o isPrivate ifTrue:[ |
951 |
class := #PrivateClass |
|
952 |
] ifFalse:[ |
|
953 |
(o isNameSpace |
|
954 |
and:[o ~~ NameSpace |
|
955 |
and:[o ~~ Smalltalk]]) |
|
956 |
ifTrue:[ |
|
957 |
class := #NameSpace |
|
958 |
] ifFalse:[ |
|
959 |
class := #Class |
|
960 |
] |
|
961 |
] |
|
7860 | 962 |
] |
6825 | 963 |
] |
964 |
] |
|
9924 | 965 |
] |
966 |
] ifFalse:[ |
|
967 |
skip := true |
|
7860 | 968 |
]. |
2651 | 969 |
]. |
9924 | 970 |
skip ifFalse:[ |
971 |
infoEntry := rawInfo at:class ifAbsent:nil. |
|
972 |
infoEntry isNil ifTrue:[ |
|
973 |
infoEntry := StatisticEntry new. |
|
974 |
rawInfo at:class put:infoEntry. |
|
975 |
]. |
|
976 |
infoEntry addStatisticForInstance:o class:class. |
|
977 |
] ifTrue:[ |
|
978 |
"/ self halt |
|
9887 | 979 |
]. |
2651 | 980 |
]. |
981 |
] valueNowOrOnUnwindDo:[ |
|
982 |
myProcess priority:myPriority. |
|
983 |
]. |
|
45 | 984 |
] |
142 | 985 |
|
6825 | 986 |
"Modified: / 19-09-1995 / 15:29:10 / claus" |
9924 | 987 |
"Modified: / 08-05-2011 / 12:35:11 / cg" |
19 | 988 |
! ! |
45 | 989 |
|
92 | 990 |
!MemoryUsageView methodsFor:'realization'! |
991 |
||
9887 | 992 |
pixelOrigin:a extent:b |
993 |
super pixelOrigin:a extent:b |
|
994 |
||
995 |
"Created: / 05-05-2011 / 17:01:06 / cg" |
|
996 |
! |
|
997 |
||
92 | 998 |
realize |
999 |
super realize. |
|
1348 | 1000 |
titleLabel origin:(list originRelativeTo:self) x @ 0.0. |
92 | 1001 |
self updateInfo. |
12892 | 1002 |
|
1003 |
"/ self sortByClass. |
|
1004 |
self sortByMemoryUsage. |
|
1005 |
||
1006 |
"/ self updateDisplay. |
|
1348 | 1007 |
|
1008 |
"Modified: 14.10.1997 / 21:03:52 / cg" |
|
92 | 1009 |
! ! |
1010 |
||
9887 | 1011 |
!MemoryUsageView::StatisticEntry methodsFor:'accessing'! |
1012 |
||
1013 |
averageSize |
|
1014 |
averageSize isNil ifTrue:[ |
|
1015 |
averageSize := overallByteSize / instanceCount |
|
1016 |
]. |
|
1017 |
^ averageSize. |
|
1018 |
||
1019 |
"Created: / 05-05-2011 / 16:09:35 / cg" |
|
1020 |
! |
|
1021 |
||
1022 |
classNameOrSymbol |
|
1023 |
^ classNameOrSymbol |
|
1024 |
! |
|
1025 |
||
1026 |
classNameStringInList |
|
1027 |
classNameOrSymbol == #Class ifTrue:[ |
|
1028 |
^ '<all classes>' |
|
1029 |
]. |
|
1030 |
classNameOrSymbol == #Metaclass ifTrue:[ |
|
1031 |
^ '<all metaclasses>' |
|
1032 |
]. |
|
1033 |
classNameOrSymbol == #PrivateMetaclass ifTrue:[ |
|
1034 |
^ '<all private meta classes>' |
|
1035 |
]. |
|
1036 |
classNameOrSymbol == #PrivateClass ifTrue:[ |
|
1037 |
^ '<all private classes>' |
|
1038 |
]. |
|
1039 |
classNameOrSymbol == #ObsoleteClass ifTrue:[ |
|
1040 |
^ '<all obsolete classes>' |
|
1041 |
]. |
|
1042 |
classNameOrSymbol == #NameSpace ifTrue:[ |
|
1043 |
^ '<all namespaces>' |
|
1044 |
]. |
|
1045 |
classNameOrSymbol isJavaClass ifTrue:[ |
|
1046 |
^ classNameOrSymbol fullName asString copyReplaceAll:$/ with:$. |
|
1047 |
]. |
|
1048 |
classNameOrSymbol isObsolete ifTrue:[ |
|
1049 |
^ classNameOrSymbol name , ' (obsolete)' |
|
1050 |
]. |
|
1051 |
^ classNameOrSymbol "displayString" name |
|
1052 |
||
1053 |
"Created: / 05-05-2011 / 16:32:58 / cg" |
|
1054 |
! |
|
1055 |
||
1056 |
instanceAllocationRate |
|
1057 |
^ instanceAllocationRate ? 0 |
|
1058 |
||
1059 |
"Modified: / 05-05-2011 / 17:10:50 / cg" |
|
1060 |
! |
|
1061 |
||
1062 |
instanceAllocationRate:something |
|
1063 |
instanceAllocationRate := something. |
|
1064 |
! |
|
1065 |
||
1066 |
instanceCount |
|
1067 |
^ instanceCount |
|
1068 |
! |
|
1069 |
||
1070 |
maxByteSize |
|
1071 |
^ maxByteSize |
|
1072 |
! |
|
1073 |
||
1074 |
memoryAllocationRate |
|
1075 |
^ memoryAllocationRate ? 0 |
|
1076 |
||
1077 |
"Modified: / 05-05-2011 / 17:10:56 / cg" |
|
1078 |
! |
|
1079 |
||
1080 |
memoryAllocationRate:something |
|
1081 |
memoryAllocationRate := something. |
|
1082 |
! |
|
1083 |
||
1084 |
minByteSize |
|
1085 |
^ minByteSize |
|
1086 |
! |
|
1087 |
||
1088 |
overallByteSize |
|
1089 |
^ overallByteSize |
|
1090 |
! ! |
|
1091 |
||
1092 |
!MemoryUsageView::StatisticEntry methodsFor:'updating'! |
|
1093 |
||
1094 |
addStatisticForInstance:o class:classNameOrSymbolArg |
|
1095 |
|bytes| |
|
1096 |
||
1097 |
bytes := ObjectMemory sizeOf:o. |
|
1098 |
instanceCount isNil ifTrue:[ |
|
1099 |
classNameOrSymbol := classNameOrSymbolArg. |
|
1100 |
overallByteSize := bytes. |
|
1101 |
minByteSize := maxByteSize := bytes. |
|
1102 |
instanceCount := 1. |
|
1103 |
] ifFalse:[ |
|
1104 |
overallByteSize := overallByteSize + bytes. |
|
1105 |
minByteSize := minByteSize min:bytes. |
|
1106 |
maxByteSize := maxByteSize max:bytes. |
|
1107 |
instanceCount := instanceCount + 1. |
|
1108 |
]. |
|
1109 |
averageSize := nil. |
|
1110 |
||
1111 |
"Created: / 05-05-2011 / 16:04:42 / cg" |
|
1112 |
! ! |
|
1113 |
||
769 | 1114 |
!MemoryUsageView class methodsFor:'documentation'! |
45 | 1115 |
|
437
9526cb043cbc
list obsolete & removed classes separately
Claus Gittinger <cg@exept.de>
parents:
165
diff
changeset
|
1116 |
version |
14921
eb71540a0256
Fix in MemoryUsageView - user self device instead of diretly accessing instvar,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14692
diff
changeset
|
1117 |
^ '$Header: /cvs/stx/stx/libtool/MemoryUsageView.st,v 1.68 2014-11-27 10:36:26 vrany Exp $' |
9339
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
1118 |
! |
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
1119 |
|
ff3e7cc06bf1
changed: #displayGlobalRefChainsToInsts
Claus Gittinger <cg@exept.de>
parents:
7950
diff
changeset
|
1120 |
version_CVS |
14921
eb71540a0256
Fix in MemoryUsageView - user self device instead of diretly accessing instvar,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14692
diff
changeset
|
1121 |
^ '$Header: /cvs/stx/stx/libtool/MemoryUsageView.st,v 1.68 2014-11-27 10:36:26 vrany Exp $' |
45 | 1122 |
! ! |
12889 | 1123 |