Jean-Paul
Jean-Paul

Reputation: 21180

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

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.

Upvotes: 6

Views: 9511

Answers (1)

Ryan Hamilton
Ryan Hamilton

Reputation: 2615

-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.)

Upvotes: 15

Related Questions