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
The image file on disk has 341.17 MiB, as of the last save. In memory, the image now has 616.53 MiB: the size of all objects after a full garbage collection, which also includes objects created by the UI and the user. The heap reserved by the virtual machine is larger, 683.14 MiB, as it also includes free space.
Total analysed size: 240.16 MiB
Methods: 78.45 MiB for 449099 methods.
The size of methods includes bytecodes, embedded blocks, the additional method state (pragmas with their arguments, and the associations holding properties) and literals. Literals include strings, literal arrays and other literals without pointers (byte arrays, large integers, floats), but exclude symbols and variable bindings. A literal shared by several methods is counted once.
String literals size: 8.27 MiB
Classes: 85.36 MiB for 32878 classess.
Instance Side: 32.02 MiB
Without method dictionaries: 14.57 MiB
By componets: 31.69 MiB
Method dictionaries: 17.45 MiB
Basic Size in Memory: 3.34 MiB
Other: 10.91 MiB
Subclasses: 297.59 KiB
Protocols: 7.18 MiB
Layout: 770.27 KiB
Shared pools: 2.69 MiB
Class side: 53.34 MiB (metaclasses)
Without method dictionaries: 31.40 MiB
By componets: 27.73 MiB
Method dictionaries: 21.95 MiB
Basic Size in Memory: 2.00 MiB
Other: 3.78 MiB
Protocols: 3.02 MiB
Layout: 770.58 KiB
By data:
Basic Size in Memory: 5.34 MiB
Method dictionaries: 39.39 MiB
Subclasses: 297.59 KiB
Protocols: 10.21 MiB
Shared pools: 2.69 MiB
Layout: 1.50 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: 7.04 MiB for 225892 symbols, and 2.48 MiB for the symbol tables that hold them
Pragmas Cache: 1.79 MiB (only the cache structure; the pragma objects are counted as part of methods)
GT Completion Cache: 61.04 MiB
Packages: 1.86 MiB
Navigation Environment: 2.13 MiB
Lepiter GT Book index: 0 B. The GT Book is the only Lepiter database saved in the image. The indexes of all loaded databases, including the ones loaded at startup, use 0 B of the heap.
Not included in the total: the whole GT Book database, including its index, uses 34.40 MiB. See Analysing the size of Lepiter databases.
Classes that use traits, or inherit from a class that uses traits, have a TraitedMetaclass
. It keeps two extra method dictionaries with the methods defined locally in the class, for the instance and the class side. Methods coming from traits are also copied into every class that uses the trait. These sizes are already included in the sizes above.
Extra method dictionaries: 25.60 MiB
Of which for classes and traits that do not use traits themselves (their extra dictionaries repeat their method dictionaries): 17.52 MiB
Methods installed from traits: 18.40 MiB for 98735 methods
This measures the size of several types of instances, to double check that the previous calculations did not miss something.
MethodDictionary
sanity check:
81366 instances
65.00 MiB using MethodDictionary>>#gtSpecificSizeInMemory
33.12 MiB using #selector
CompiledMethod
:
449329 instances
79.60 MiB using CompiledMethod>>#gtSpecificSizeInMemory
38.87 MiB using #selector
CompiledBlock
instances
139638 instances
8.22 MiB using #selector