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 << #GtMemoryMetrics slots: { #cache }; package: 'GToolkit-Releaser' . They can be reset using the snippet below.

GtMemoryMetrics reset
  

Current image size is 650.75 MiB.

Total analysed size: 230.98 MiB

Methods: 64.08 MiB for 435649 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.48 MiB

Classes: 94.17 MiB for 31843 classess.

Instance Side: 38.08 MiB

Without method dictionaries: 13.45 MiB

By componets: 37.68 MiB

Method dictionaries: 24.63 MiB

Basic Size in Memory: 3.23 MiB

Other: 9.82 MiB

Subclasses: 288.79 KiB

Protocols: 6.22 MiB

Layout: 746.01 KiB

Shared pools: 2.59 MiB

Class side: 56.09 MiB (metaclasses)

Without method dictionaries: 32.53 MiB

By componets: 28.88 MiB

Method dictionaries: 23.55 MiB

Basic Size in Memory: 1.94 MiB

Other: 3.39 MiB

Protocols: 2.66 MiB

Layout: 746.32 KiB

By data:

Basic Size in Memory: 5.17 MiB

Method dictionaries: 48.19 MiB

Subclasses: 288.79 KiB

Protocols: 8.88 MiB

Shared pools: 2.59 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.63 MiB for 215201 symbols

Pragmas Cache: 5.11 MiB

GT Completion Cache: 57.07 MiB

Packages: 1.85 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 Dictionary << #MethodDictionary layout: VariableLayout; slots: {}; tag: 'Methods'; package: 'Kernel-CodeModel' sanity check:

78954 instances

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

32.28 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 << #CompiledMethod layout: CompiledMethodLayout; slots: {}; tag: 'Methods'; package: 'Kernel-CodeModel' :

435810 instances

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

36.97 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

CompiledBlock CompiledCode << #CompiledBlock layout: CompiledMethodLayout; slots: {}; tag: 'Methods'; package: 'Kernel-CodeModel' instances

125765 instances

7.33 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