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 600.93 MiB.

Total analysed size: 219.55 MiB

Methods: 60.11 MiB for 419438 methods.

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

String literals size: 6.79 MiB

Classes: 89.74 MiB for 30570 classess.

Instance Side: 36.42 MiB

Without method dictionaries: 12.89 MiB

By componets: 36.02 MiB

Method dictionaries: 23.53 MiB

Basic Size in Memory: 3.10 MiB

Other: 9.39 MiB

Subclasses: 277.11 KiB

Protocols: 5.98 MiB

Layout: 716.17 KiB

Shared pools: 2.44 MiB

Class side: 53.32 MiB (metaclasses)

Without method dictionaries: 30.96 MiB

By componets: 27.51 MiB

Method dictionaries: 22.36 MiB

Basic Size in Memory: 1.86 MiB

Other: 3.28 MiB

Protocols: 2.59 MiB

Layout: 716.48 KiB

By data:

Basic Size in Memory: 4.96 MiB

Method dictionaries: 45.90 MiB

Subclasses: 277.11 KiB

Protocols: 8.56 MiB

Shared pools: 2.44 MiB

Layout: 1.40 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.34 MiB for 207343 symbols

Pragmas Cache: 4.92 MiB

GT Completion Cache: 54.61 MiB

Packages: 1.80 MiB

Navigation Environment: 2.02 MiB

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

Traits overhead: 12.38 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:

75752 instances

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

30.64 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' :

419600 instances

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

35.44 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

120874 instances

7.06 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 << #ClassOrganization slots: {}; package: 'GToolkit-Pharo11Stubs' :

0 instances

0 B using ClassOrganization>>#gtSpecificSizeInMemory gtSpecificSizeInMemory ^ self sizeInMemory + protocolOrganizer gtSpecificSizeInMemory