QStudio
Query kdb+ Servers and Chart Results.
Kdb uses a variant of the buddy memory system using reference counting for tracking live objects.
Memory for objects < 32MB will come from an internal heap which can only ever grow - this memory is given back to the heap when the object is no longer referenced, and can be used again for further allocations < 32MB.
Version | Behaviour |
---|---|
2.4 | Memory never returned |
2.5/2.6 | Unreferenced memory blocks over 32MB/64MB are returned immediately |
2.7 | Unreferenced memory blocks returned when memory full or .Q.gc[] called |
The following commands can be used to get memory usage
All values are in bytes
In older versions of q, .Q.w[] was not present. The older, less user friendly way of obtaining the above statistics is
(since 2.7) invokes the garbage collector. Returns the amount of memory that was returned to the OS.
Switch garbage collection between immediate (1) and deferred (0) modes.
The C API details reference couting as encountered when extending kdb using C
From within kdb we can use -16! - Returns the number of references to an object
Vectors are copied by reference when possible, but editing just one value causes another entire vector to be allocated. Note columns in a table are just vectors as shown below:
There are two modes of memory mapping - immediate and deferred:
Uncompressed columns are stored in memory for the duration of a query, this can significantly increase memory requirements.
Query kdb+ Servers and Chart Results.