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 633.45 MiB.
Total analysed size: 231.52 MiB
Methods: 64.19 MiB for 436465 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.50 MiB
Classes: 94.43 MiB for 31947 classess.
Instance Side: 38.20 MiB
Without method dictionaries: 13.49 MiB
By componets: 37.80 MiB
Method dictionaries: 24.71 MiB
Basic Size in Memory: 3.24 MiB
Other: 9.85 MiB
Subclasses: 289.77 KiB
Protocols: 6.24 MiB
Layout: 748.45 KiB
Shared pools: 2.60 MiB
Class side: 56.22 MiB (metaclasses)
Without method dictionaries: 32.60 MiB
By componets: 28.96 MiB
Method dictionaries: 23.63 MiB
Basic Size in Memory: 1.95 MiB
Other: 3.39 MiB
Protocols: 2.66 MiB
Layout: 748.76 KiB
By data:
Basic Size in Memory: 5.18 MiB
Method dictionaries: 48.34 MiB
Subclasses: 289.77 KiB
Protocols: 8.90 MiB
Shared pools: 2.60 MiB
Layout: 1.46 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.65 MiB for 215723 symbols
Pragmas Cache: 5.12 MiB
GT Completion Cache: 57.20 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.84 MiB
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
79186 instances
75.58 MiB using HashedCollection>>#gtSpecificSizeInMemory
32.37 MiB using #selector
CompiledMethod
:
436626 instances
64.22 MiB using CompiledMethod>>#gtSpecificSizeInMemory
37.04 MiB using #selector
CompiledBlock
instances
126079 instances
7.35 MiB using #selector