/* Spurious Coverity warnings be gone. */
clib_memset (&trace, 0, sizeof (trace));
- /* Skip our frame and mspace_get_aligned's frame */
- n_callers = clib_backtrace (trace.callers, ARRAY_LEN (trace.callers), 2);
- if (n_callers == 0)
- return;
-
clib_spinlock_lock (&tm->lock);
/* Turn off tracing to avoid embarrassment... */
save_enabled = tm->enabled;
tm->enabled = 0;
+ /* Skip our frame and mspace_get_aligned's frame */
+ n_callers = clib_backtrace (trace.callers, ARRAY_LEN (trace.callers), 2);
+ if (n_callers == 0)
+ goto out;
+
if (!tm->trace_by_callers)
tm->trace_by_callers =
hash_create_shmem (0, sizeof (trace.callers), sizeof (uword));
t->n_bytes += size;
t->offset = offset; /* keep a sample to autopsy */
hash_set (tm->trace_index_by_offset, offset, t - tm->traces);
+
+out:
tm->enabled = save_enabled;
clib_spinlock_unlock (&tm->lock);
}
{
struct dlmallinfo mi = mspace_mallinfo (heap->mspace);
- /* TODO: Fill in some more values */
+ usage->bytes_total = mi.arena; /* non-mmapped space allocated from system */
+ usage->bytes_used = mi.uordblks; /* total allocated space */
+ usage->bytes_free = mi.fordblks; /* total free space */
+ usage->bytes_used_mmap = mi.hblkhd; /* space in mmapped regions */
+ usage->bytes_max = mi.usmblks; /* maximum total allocated space */
+ usage->bytes_free_reclaimed = mi.ordblks; /* number of free chunks */
+ usage->bytes_overhead = mi.keepcost; /* releasable (via malloc_trim) space */
+
+ /* Not supported */
+ usage->bytes_used_sbrk = 0;
usage->object_count = 0;
- usage->bytes_total = mi.arena;
- usage->bytes_overhead = 0;
- usage->bytes_max = 0;
- usage->bytes_used = mi.uordblks;
- usage->bytes_free = mi.fordblks;
- usage->bytes_free_reclaimed = 0;
}
/* Call serial number for debugger breakpoints. */