602SQL Documentation Index  

_IV_MEMORY_USAGE System Query

The system query _iv_memory_usage returns a complete dump of SQL server memory allocations. The results can be used for solving problems with a memory usage and allocations.

Column description

Column name Type Contents
Owner_code INT The row with a code = 0 shows the size of a free memory, rest of the rows show single "types" of a memory.
Bytes INT Size of allocated memory (in bytes).
Items INT Number of allocations.

Example

Write results to the server log:

PROCEDURE `log_memory`(  );
/******************************************************/
BEGIN
  DECLARE p1 CHAR(3);

  CALL Log_write('-------------- MEMORY LOG --------------');
  FOR r AS CURSOR FOR
    SELECT * FROM _iv_memory_usage              
  DO
    IF r.owner_code<10 THEN SET p1 = '  '||Int2str(r.owner_code);
    ELSEIF r.owner_code<100 THEN SET p1 = ' '||Int2str(r.owner_code);
    ELSE SET p1 = Int2str(r.owner_code);
    END IF;
    CALL Log_write(p1||':'||Int2str(r.bytes)||'/'||Int2str(r.items));
  END FOR;
  CALL Log_write('-------------- MEMORY LOG --------------');
END