_C_TS_malloc_info() — Determine amount of teraspace memory used

Format

#include <mallocinfo.h>
int _C_TS_malloc_info(struct _C_mallinfo_t *output_record, size_t sizeofoutput);

Language Level: Extended

Threadsafe: Yes.

Description

The _C_TS_malloc_info() function determines the amount of teraspace memory used and returns the information within the given output_record structure.

Note:
This function is for low-level debug of teraspace memory usage within an application.

Return Value

If successful, the function returns 0. If an error occurs, the function returns a negative value.

Example that uses _C_TS_malloc_info()

This example prints the information returned from _C_TS_malloc_info() to stdout . This program is compiled with TERASPACE(*YES *TSIFC).

#include <stdio.h>
#include <stdlib.h>
#include <mallocinfo.h>
 
int main (void)
{
   _C_mallinfo_t info;
   int           rc;
   void         *m;

   /* Allocate a small chunk of memory */
   m = malloc(500);

   rc = _C_TS_malloc_info(&info, sizeof(info));

   if (rc == 0) {
      printf("Total bytes              = %llu\n",
             info.total_bytes);
      printf("Total allocated bytes    = %llu\n",
             info.allocated_bytes);
      printf("Total unallocated bytes  = %llu\n",
             info.unallocated_bytes);
      printf("Total allocated blocks   = %llu\n",
             info.allocated_blocks);
      printf("Total unallocated blocks = %llu\n",
             info.unallocated_blocks);
      printf("Total requested bytes    = %llu\n",
             info.requested_bytes);
      printf("Total pad bytes          = %llu\n",
             info.pad_bytes);
      printf("Total overhead bytes     = %llu\n",
             info.overhead_bytes);
   }
   else {
      printf("_C_TS_malloc_info failed (rc = %d)\n", rc);
   }

   free(m);
}

/****************************************************
  The output should be similar to:

   Total bytes              = 524288
   Total allocated bytes    = 688
   Total unallocated bytes  = 523600
   Total allocated blocks   = 1
   Total unallocated blocks = 1
   Total requested bytes    = 500
   Total pad bytes          = 12
   Total overhead bytes     = 176
 ****************************************************

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]