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