How to get the total size of a table in kdb+?
Asked Answered
S

1

6

I'm trying to find the memory usage of an in-memory table in q. How can I display this?

It is receiving live updates and I would like to keep track of the total used memory of such a table.

I can't seem to find any relevant functions/commands for this. I need something like hcount for file locations, but an in-memory version.

Splint answered 2/2, 2015 at 20:54 Comment(0)
A
15

-22! returns the size in bytes of in-memory objects. e.g.

  q)t:([] a:til 1000)
  q)-22!t
8031
  q)/ 1000 longs = 1000*8 bytes + a small header
  q)t:([] a:til 2000)
  q)-22!t
16031

If you are interested in how memory management in kdb works I recommend this tutorial: http://www.timestored.com/kdb-guides/memory-management (Disclaimer: I wrote it.)

Adellaadelle answered 2/2, 2015 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.