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 673.25 MiB.
Total analysed size: 226.25 MiB
Methods: 62.20 MiB for 428219 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.64 MiB
Classes: 92.53 MiB for 31335 classess.
Instance Side: 37.38 MiB
Without method dictionaries: 13.22 MiB
By componets: 36.99 MiB
Method dictionaries: 24.16 MiB
Basic Size in Memory: 3.18 MiB
Other: 9.65 MiB
Subclasses: 284.42 KiB
Protocols: 6.12 MiB
Layout: 734.10 KiB
Shared pools: 2.53 MiB
Class side: 55.14 MiB (metaclasses)
Without method dictionaries: 32.03 MiB
By componets: 28.37 MiB
Method dictionaries: 23.12 MiB
Basic Size in Memory: 1.91 MiB
Other: 3.34 MiB
Protocols: 2.62 MiB
Layout: 734.41 KiB
By data:
Basic Size in Memory: 5.09 MiB
Method dictionaries: 47.28 MiB
Subclasses: 284.42 KiB
Protocols: 8.75 MiB
Shared pools: 2.53 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.51 MiB for 211811 symbols
Pragmas Cache: 5.04 MiB
GT Completion Cache: 56.08 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.65 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
77736 instances
74.04 MiB using HashedCollection>>#gtSpecificSizeInMemory
31.70 MiB using #selector
CompiledMethod
:
428380 instances
62.23 MiB using CompiledMethod>>#gtSpecificSizeInMemory
36.30 MiB using #selector
CompiledBlock
instances
123857 instances
7.22 MiB using #selector