Memory Requirements - macmcmeans/localDataStorage GitHub Wiki

👉🏻 View this page without sidebar

There is a difference between the memory required to store a key value and the memory consumed in the process. For JavaScript, consumption is doubled that of storage.

The following table illustrates memory storage and consumption, for both a key name and its value, as well as the available methods for determining each:

Prefix Example Key Value Key
Name
Key
Memory
Storage
keybytes
Full Key
Memory
Storage ⑴
keybytesall
Full Key
Memory
Consumed
keybytesmem
Data
Type
Data
Value
Internally
Stored As
Value
Memory
Storage
valbytes
Full Value
Memory
Storage ⑵
valbytesall
Full Value
Memory
Consumed
valbytesmem
lds-1. .set( 'skey1', '["x"]' ) skey1 5 bytes 11 bytes 22 bytes Array ["x"] ["x"]� 5 bytes 6 bytes 12 bytes
.set( 'skey1', 12n ) BigInt 12n 12� 2 bytes 3 bytes 6 bytes
.set( 'skey1', true ) Boolean true 1� 1 byte 2 bytes 4 bytes
.set( 'skey1', false ) Boolean false 0� 1 byte 2 bytes 4 bytes
.set( 'skey1', Date() ) Date ~ ZVRnbZS� ⑸ 7 bytes 8 bytes 16 bytes
.set( 'skey1', 2149.99 ) Float 2149.99 1w.14� ⑹ 5 bytes 6 bytes 12 bytes
.set( 'skey1', 9182736450 ) Integer 9182736450 1g]vJ(� ⑹ 6 bytes 7 bytes 14 bytes
.set( 'skey1', null ) null null null� 4 bytes 5 bytes 10 bytes
.set( 'skey1', {'a':1} ) Object {'a':1} {'a':1}� 7 bytes 8 bytes 16 bytes
.set( 'skey1', 'lds' ) String 'lds' lds� 3 bytes 4 bytes 8 bytes
.set( 'skey1', 'this is some string data' ) Compressed
String
'this is some string data' \x9B8\x17³l>ÃF¥'þa� ⑷ 17 bytes 18 bytes 36 bytes ⑶



Footnotes:
⑴ includes the namespace prefix (6 bytes, in this example)
⑵ includes the data type marker flag (always 1 byte)
⑶ text compression—even on a small scale—makes an impact (uncompressed this string consumes 24 bytes, not 17)
⑷ note that string length is inconsequential (13 in this case); for storage the only metric that counts is byte count
⑸ dates are automatically stored compressed, providing a degree of obfuscation as well
⑹ numbers (floats and integers) are automatically stored compressed, providing a degree of obfuscation as well

⚠️ **GitHub.com Fallback** ⚠️