Analysing the size of code-related entities
This page provides an analysis for the size of the image, with a focus on the size of code entities, like methods and classes.
For performance reasons the vaues of these metrics are caches in GtMemoryMetrics
. They can be reset using the snippet below.
GtMemoryMetrics reset
Current image size is 552.12 MiB.
Total analysed size: 219.13 MiB
Methods: 59.99 MiB for 418885 methods.
The size of methods includes all bytecodes, additional state and literals. Literals include strings and literal arrays, but excludes symbols.
String literals size: 6.77 MiB
Classes: 89.63 MiB for 30509 classess.
Instance Side: 36.35 MiB
Without method dictionaries: 12.86 MiB
By componets: 35.95 MiB
Method dictionaries: 23.49 MiB
Basic Size in Memory: 3.09 MiB
Other: 9.37 MiB
Subclasses: 276.55 KiB
Protocols: 5.97 MiB
Layout: 714.74 KiB
Shared pools: 2.44 MiB
Class side: 53.29 MiB (metaclasses)
Without method dictionaries: 30.95 MiB
By componets: 27.47 MiB
Method dictionaries: 22.33 MiB
Basic Size in Memory: 1.86 MiB
Other: 3.28 MiB
Protocols: 2.58 MiB
Layout: 715.05 KiB
By data:
Basic Size in Memory: 4.95 MiB
Method dictionaries: 45.82 MiB
Subclasses: 276.55 KiB
Protocols: 8.55 MiB
Shared pools: 2.44 MiB
Layout: 1.40 MiB
The size of classes includes the size of the class object and various method dictionaries, but excludes the actual methods in those dictionaries
Symbols: 6.33 MiB for 206966 symbols
Pragmas Cache: 4.91 MiB
GT Completion Cache: 54.44 MiB
Packages: 1.80 MiB
Navigation Environment: 2.01 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.38 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
75630 instances
71.62 MiB using HashedCollection>>#gtSpecificSizeInMemory
30.60 MiB using #selector
CompiledMethod
:
419047 instances
60.02 MiB using CompiledMethod>>#gtSpecificSizeInMemory
35.38 MiB using #selector
CompiledBlock
instances
120583 instances
7.03 MiB using #selector
ClassOrganization
:
0 instances
0 B using ClassOrganization>>#gtSpecificSizeInMemory