source: rtems/cpukit/libcsupport/src/malloc_report_statistics_plugin.c @ 98b785e

4.115
Last change on this file since 98b785e was 7c411bd, checked in by Joel Sherrill <joel.sherrill@…>, on 09/14/09 at 14:48:38

2009-09-14 Sebastian Huber <Sebastian.Huber@…>

  • score/src/wkspace.c: Removed work space area consistency checks.
  • libblock/include/rtems/ide_part_table.h: Functions are now deprecated.
  • libcsupport/include/rtems/libcsupport.h, libcsupport/src/calloc.c, libcsupport/src/malloc_boundary.c, libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_report_statistics_plugin.c, libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, rtems/inline/rtems/rtems/region.inl: Update for heap API changes.

2009-09-14 Christian Mauderer <christian.mauderer@…>

  • libcsupport/src/vprintk.c: Fixed warnings. Print nothing in case the pointer to the string is NULL.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  malloc_report_statistics with plugin Implementation
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#ifdef RTEMS_NEWLIB
19#include "malloc_p.h"
20#include "inttypes.h"
21
22void malloc_report_statistics_with_plugin(
23  void                  *context,
24  rtems_printk_plugin_t  print
25)
26{
27  rtems_malloc_statistics_t *s;
28  uintmax_t allocated;
29
30  s = &rtems_malloc_statistics;
31
32  allocated  = s->lifetime_allocated - s->lifetime_freed;
33
34  (*print)(
35    context,
36    "Malloc statistics\n"
37    "  avail:%"PRIu32"k  allocated:%"PRIu32"k (%"PRId32"%%) "
38      "max:%"PRIu32"k (%"PRIu32"%%)"
39      " lifetime:%"PRIu32"k freed:%"PRIu32"k\n",
40    s->space_available / 1024,
41    allocated / 1024,
42    /* avoid float! */
43    (allocated * 100) / s->space_available,
44    s->max_depth / 1024,
45    (s->max_depth * 100) / s->space_available,
46    (uint32_t) (s->lifetime_allocated / 1024),
47    (uint32_t) (s->lifetime_freed / 1024)
48  );
49  (*print)(
50    context,
51    "  Call counts:   malloc:%"PRIu32"   memalign:%"PRIu32"   free:%"PRIu32
52       "   realloc:%"PRIu32"   calloc:%"PRIu32"\n",
53    s->malloc_calls,
54    s->memalign_calls,
55    s->free_calls,
56    s->realloc_calls,
57    s->calloc_calls
58  );
59}
60
61#endif
Note: See TracBrowser for help on using the repository browser.