The output from this unit-test seems correct. Moreover, "memory-trace" ... do 
some stuff ... "show memory verbose" also seems pretty sensible...

HTH... Dave

static clib_error_t *
test_memory_trace_command_fn (vlib_main_t * vm,
                              unformat_input_t * input,
                              vlib_cli_command_t * cmd)
{
  int leak = 0;
  u8 *s;
  u8 *item = 0;
  int i;

  if (unformat (input, "leak"))
    leak = 1;

  clib_mem_trace (1);

  item = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES);

  if (leak == 0)
    clib_mem_free (item);

  (void) clib_mem_trace_enable_disable (0);

  s = format (0, "%U", format_mheap, clib_mem_get_heap(), 1 /* verbose */);

  if (leak == 1)
    clib_mem_free (item);

  clib_mem_trace (0);

  vlib_cli_output (vm, "direct alloc: %v", s);
  vec_free (s);

  clib_mem_trace (1);

  item = 0;

  for (i = 0; i < 1000; i++)
    vec_add1 (item, i);

  if (leak == 0)
    vec_free (item);

  (void) clib_mem_trace_enable_disable (0);

  s = format (0, "%U", format_mheap, clib_mem_get_heap(), 1 /* verbose */);

  if (leak == 1)
    vec_free (item);

  clib_mem_trace (0);

  vlib_cli_output (vm, "vector alloc: %v", s);
  vec_free (s);

  return 0;
}

/* *INDENT-OFF* */
VLIB_CLI_COMMAND (test_memory_trace_command, static) = {
  .path = "test memory-trace",
  .short_help = "test memory-trace [leak]",
  .function = test_memory_trace_command_fn,
};
/* *INDENT-ON* */

Thanks... Dave

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13070): https://lists.fd.io/g/vpp-dev/message/13070
Mute This Topic: https://lists.fd.io/mt/31648681/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to