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 Object subclass: #GtMemoryMetrics instanceVariableNames: 'cache' classVariableNames: '' package: 'GToolkit-Releaser' . They can be reset using the snippet below.

GtMemoryMetrics reset
  

Current image size is 455.64 MiB.

Total analysed size: InstanceVariableNotFound: methodSelectors not found in AllProtocol (no messages) - 0 selector(s)

Methods: 51.42 MiB for 371367 methods.

The size of methods includes all bytecodes, additional state and literals. Literals include strings and literal arrays, but excludes symbols.

Classes: InstanceVariableNotFound: methodSelectors not found in AllProtocol (no messages) - 0 selector(s) for 26580 classess.

Instance Side: InstanceVariableNotFound: methodSelectors not found in AllProtocol (-- all --) - 7 selector(s)

Class side: InstanceVariableNotFound: methodSelectors not found in AllProtocol (no messages) - 0 selector(s) (metaclasses)

The size of classes includes the size of the class object and various method dictionaries, but excludes the actual methods in those dictionaries

Symbols: 5.91 MiB for 191881 symbols

Pragmas Cache: 1.86 MiB

GT Completion Cache: 46.91 MiB

Packages: 9.93 MiB

Navigation Environment: 1.83 MiB

When using traits, metaclasses use two extra arrays. This can introduce a memory overhead when traits have many users.

Traits overhead: 10.10 MiB

This measures the size of several types of instances, to double check that the previous calculations did not miss something.

MethodDictionary Dictionary variableSubclass: #MethodDictionary instanceVariableNames: '' classVariableNames: '' package: 'Kernel-Methods' sanity check:

65866 instances

60.87 MiB using HashedCollection>>#gtSpecificSizeInMemory gtSpecificSizeInMemory ^ self sizeInMemory + array sizeInMemory

25.83 MiB using #selector instancesSizeInMemory "Answers the number of bytes consumed by all its instances including their object header. Note: we do not use #allInstances as allInstancesDo: has a fallback for low memory" | bytes | bytes := 0. self allInstancesDo: [:each | bytes := bytes + each sizeInMemory ]. ^ bytes

CompiledMethod CompiledCode variableByteSubclass: #CompiledMethod instanceVariableNames: '' classVariableNames: '' package: 'Kernel-Methods' :

371623 instances

51.47 MiB using CompiledMethod>>#gtSpecificSizeInMemory gtSpecificSizeInMemory ^ super gtSpecificSizeInMemory + (self penultimateLiteral isMethodProperties ifTrue: [ self penultimateLiteral sizeInMemory ] ifFalse: [ 0 ])

31.03 MiB using #selector instancesSizeInMemory "Answers the number of bytes consumed by all its instances including their object header. Note: we do not use #allInstances as allInstancesDo: has a fallback for low memory" | bytes | bytes := 0. self allInstancesDo: [:each | bytes := bytes + each sizeInMemory ]. ^ bytes

ClassOrganization Object subclass: #ClassOrganization instanceVariableNames: 'protocolOrganizer organizedClass commentSourcePointer' classVariableNames: '' package: 'Kernel-Protocols' :

53160 instances

InstanceVariableNotFound: methodSelectors not found in AllProtocol (-- all --) - 1 selector(s) using ClassOrganization>>#gtSpecificSizeInMemory gtSpecificSizeInMemory ^ self sizeInMemory + protocolOrganizer gtSpecificSizeInMemory