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 653.62 MiB.
Total analysed size: 232.16 MiB
Methods: 64.40 MiB for 435157 methods.
The size of methods includes all bytecodes, additional state and literals. Literals include strings and literal arrays, but excludes symbols.
String literals size: 8.59 MiB
Classes: 94.48 MiB for 32037 classess.
Instance Side: 38.18 MiB
Without method dictionaries: 13.45 MiB
By componets: 37.85 MiB
Method dictionaries: 24.72 MiB
Basic Size in Memory: 3.25 MiB
Other: 9.88 MiB
Subclasses: 290.57 KiB
Protocols: 6.25 MiB
Layout: 750.55 KiB
Shared pools: 2.61 MiB
Class side: 56.30 MiB (metaclasses)
Without method dictionaries: 32.63 MiB
By componets: 29.02 MiB
Method dictionaries: 23.67 MiB
Basic Size in Memory: 1.95 MiB
Other: 3.39 MiB
Protocols: 2.66 MiB
Layout: 750.87 KiB
By data:
Basic Size in Memory: 5.20 MiB
Method dictionaries: 48.40 MiB
Subclasses: 290.57 KiB
Protocols: 8.91 MiB
Shared pools: 2.61 MiB
Layout: 1.47 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.66 MiB for 215656 symbols
Pragmas Cache: 5.15 MiB
GT Completion Cache: 57.52 MiB
Packages: 1.86 MiB
Navigation Environment: 2.08 MiB
When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.
Traits overhead: 12.75 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
79438 instances
75.67 MiB using HashedCollection>>#gtSpecificSizeInMemory
32.46 MiB using #selector
CompiledMethod
:
435317 instances
64.43 MiB using CompiledMethod>>#gtSpecificSizeInMemory
37.11 MiB using #selector
CompiledBlock
instances
127030 instances
7.40 MiB using #selector