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 626.45 MiB.
Total analysed size: 225.16 MiB
Methods: 61.91 MiB for 426590 methods.
The size of methods includes all bytecodes, additional state and literals. Literals include strings and literal arrays, but excludes symbols.
String literals size: 7.62 MiB
Classes: 92.10 MiB for 31198 classess.
Instance Side: 37.20 MiB
Without method dictionaries: 13.16 MiB
By componets: 36.80 MiB
Method dictionaries: 24.04 MiB
Basic Size in Memory: 3.16 MiB
Other: 9.60 MiB
Subclasses: 283.17 KiB
Protocols: 6.09 MiB
Layout: 730.89 KiB
Shared pools: 2.51 MiB
Class side: 54.90 MiB (metaclasses)
Without method dictionaries: 31.90 MiB
By componets: 28.24 MiB
Method dictionaries: 23.01 MiB
Basic Size in Memory: 1.90 MiB
Other: 3.33 MiB
Protocols: 2.62 MiB
Layout: 731.20 KiB
By data:
Basic Size in Memory: 5.06 MiB
Method dictionaries: 47.05 MiB
Subclasses: 283.17 KiB
Protocols: 8.71 MiB
Shared pools: 2.51 MiB
Layout: 1.43 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.47 MiB for 210870 symbols
Pragmas Cache: 5.03 MiB
GT Completion Cache: 55.77 MiB
Packages: 1.83 MiB
Navigation Environment: 2.05 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.60 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
77414 instances
73.70 MiB using HashedCollection>>#gtSpecificSizeInMemory
31.55 MiB using #selector
CompiledMethod
:
426751 instances
61.94 MiB using CompiledMethod>>#gtSpecificSizeInMemory
36.14 MiB using #selector
CompiledBlock
instances
122887 instances
7.16 MiB using #selector
ClassOrganization
:
0 instances
0 B using ClassOrganization>>#gtSpecificSizeInMemory