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 621.07 MiB.
Total analysed size: 222.67 MiB
Methods: 61.50 MiB for 423339 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.59 MiB
Classes: 90.61 MiB for 30911 classess.
Instance Side: 36.84 MiB
Without method dictionaries: 13.03 MiB
By componets: 36.45 MiB
Method dictionaries: 23.81 MiB
Basic Size in Memory: 3.14 MiB
Other: 9.50 MiB
Subclasses: 280.02 KiB
Protocols: 6.04 MiB
Layout: 724.16 KiB
Shared pools: 2.48 MiB
Class side: 53.76 MiB (metaclasses)
Without method dictionaries: 31.16 MiB
By componets: 27.79 MiB
Method dictionaries: 22.60 MiB
Basic Size in Memory: 1.88 MiB
Other: 3.31 MiB
Protocols: 2.60 MiB
Layout: 724.48 KiB
By data:
Basic Size in Memory: 5.02 MiB
Method dictionaries: 46.41 MiB
Subclasses: 280.02 KiB
Protocols: 8.64 MiB
Shared pools: 2.48 MiB
Layout: 1.41 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.41 MiB for 209196 symbols
Pragmas Cache: 4.99 MiB
GT Completion Cache: 55.32 MiB
Packages: 1.81 MiB
Navigation Environment: 2.03 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.43 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
76508 instances
72.37 MiB using HashedCollection>>#gtSpecificSizeInMemory
30.93 MiB using #selector
CompiledMethod
:
423501 instances
61.53 MiB using CompiledMethod>>#gtSpecificSizeInMemory
35.86 MiB using #selector
CompiledBlock
instances
122227 instances
7.15 MiB using #selector
ClassOrganization
:
0 instances
0 B using ClassOrganization>>#gtSpecificSizeInMemory