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 562.85 MiB.
Total analysed size: 217.54 MiB
Methods: 59.63 MiB for 416690 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.70 MiB
Classes: 88.88 MiB for 30327 classess.
Instance Side: 36.12 MiB
Without method dictionaries: 12.78 MiB
By componets: 35.72 MiB
Method dictionaries: 23.34 MiB
Basic Size in Memory: 3.08 MiB
Other: 9.30 MiB
Subclasses: 275.02 KiB
Protocols: 5.93 MiB
Layout: 710.48 KiB
Shared pools: 2.42 MiB
Class side: 52.77 MiB (metaclasses)
Without method dictionaries: 30.64 MiB
By componets: 27.24 MiB
Method dictionaries: 22.13 MiB
Basic Size in Memory: 1.85 MiB
Other: 3.27 MiB
Protocols: 2.57 MiB
Layout: 710.79 KiB
By data:
Basic Size in Memory: 4.92 MiB
Method dictionaries: 45.47 MiB
Subclasses: 275.02 KiB
Protocols: 8.50 MiB
Shared pools: 2.42 MiB
Layout: 1.39 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.30 MiB for 205957 symbols
Pragmas Cache: 4.89 MiB
GT Completion Cache: 54.04 MiB
Packages: 1.79 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.32 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
75130 instances
70.98 MiB using HashedCollection>>#gtSpecificSizeInMemory
30.32 MiB using #selector
CompiledMethod
:
416852 instances
59.66 MiB using CompiledMethod>>#gtSpecificSizeInMemory
35.19 MiB using #selector
CompiledBlock
instances
119784 instances
6.98 MiB using #selector
ClassOrganization
:
0 instances
0 B using ClassOrganization>>#gtSpecificSizeInMemory