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 575.02 MiB.
Total analysed size: 215.21 MiB
Methods: 59.04 MiB for 412528 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.61 MiB
Classes: 87.89 MiB for 29976 classess.
Instance Side: 35.65 MiB
Without method dictionaries: 12.62 MiB
By componets: 35.25 MiB
Method dictionaries: 23.03 MiB
Basic Size in Memory: 3.04 MiB
Other: 9.19 MiB
Subclasses: 271.63 KiB
Protocols: 5.86 MiB
Layout: 702.25 KiB
Shared pools: 2.37 MiB
Class side: 52.24 MiB (metaclasses)
Without method dictionaries: 30.39 MiB
By componets: 26.92 MiB
Method dictionaries: 21.85 MiB
Basic Size in Memory: 1.83 MiB
Other: 3.24 MiB
Protocols: 2.55 MiB
Layout: 702.56 KiB
By data:
Basic Size in Memory: 4.87 MiB
Method dictionaries: 44.88 MiB
Subclasses: 271.63 KiB
Protocols: 8.42 MiB
Shared pools: 2.37 MiB
Layout: 1.37 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.26 MiB for 204903 symbols
Pragmas Cache: 4.86 MiB
GT Completion Cache: 53.39 MiB
Packages: 1.78 MiB
Navigation Environment: 1.99 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.15 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
74334 instances
70.19 MiB using HashedCollection>>#gtSpecificSizeInMemory
29.97 MiB using #selector
CompiledMethod
:
412691 instances
59.07 MiB using CompiledMethod>>#gtSpecificSizeInMemory
34.84 MiB using #selector
CompiledBlock
instances
118356 instances
6.90 MiB using #selector
ClassOrganization
:
0 instances
0 B using ClassOrganization>>#gtSpecificSizeInMemory