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 529.03 MiB.
Total analysed size: 234.48 MiB
Methods: 58.45 MiB for 414465 methods.
The size of methods includes all bytecodes, additional state and literals. Literals include strings and literal arrays, but excludes symbols.
Classes: 101.08 MiB for 29426 classess.
Instance Side: 43.12 MiB
Class side: 57.96 MiB (metaclasses)
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.52 MiB for 209900 symbols
Pragmas Cache: 2.85 MiB
GT Completion Cache: 52.70 MiB
Packages: 10.92 MiB
Navigation Environment: 1.96 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.02 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
73320 instances
70.22 MiB using HashedCollection>>#gtSpecificSizeInMemory
29.95 MiB using #selector
CompiledMethod
:
414644 instances
58.49 MiB using CompiledMethod>>#gtSpecificSizeInMemory
34.89 MiB using #selector
ClassOrganization
:
58852 instances
22.80 MiB using ClassOrganization>>#gtSpecificSizeInMemory