Skip to content

Memory Requirements

W. "Mac" McMeans edited this page Aug 11, 2022 · 25 revisions

👉🏻 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
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', 19.99 ) Float 19.99 19.99� 5 bytes 6 bytes 12 bytes
.set( 'skey1', 1234 ) Integer 1234 1234� 4 bytes 5 bytes 10 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', 'test string' ) 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 would consume 24 bytes, not 17)
⑷ note that the length of the string is inconsequential (13 in this case); for storage the only metric that counts is the byte count

localStorage Keys

The usual suspects:

set / get      clear      key      remove

The esoteric ones:

Array Keys:
push / pull, pullall      poke      contains      where

Broadcasting:
broadcast

Bypass:
forceset / forceget

Data Transfer:
import / export

Duplicates:
countdupes, showdupes, listdupes

Internals:
cancrunch      crunch / uncrunch

shufflestring / unshufflestring

xorstring

Management:
keys

Memory Consumption:

Memory Quota:
showquota

Query:
haskey, hasval, hastype

Security:
safeset / safeget

setscramblekey / getscramblekey

Type Check:
isarray      isbigint      isboolean      iscrunch

isdate      isfloat      isinteger      isnull

isnumber      isobject      isstring

showtype

Utility:
chopget      copy      softset      rename

Properties:

channel      length      quota      version

Settings:

verbosity

Memory Keys

Standard:

_set / _get      _clear      _key      _remove

Unconventional:

Data Sync:
_backup / _restore

Management:
_keys

Security:
_safeset / _safeget

Type Check:
_isarray      _isbigint      _isboolean      _iscrunch

_isdate      _isfloat      _isinteger      _isnull

_isnumber      _isobject      _isstring

_showtype

Utility:
_chopget      _copy      _softset      _rename

Clone this wiki locally