malloc.c line 329
Aaron J. Grier
aaron at frye.com
Sat Nov 6 00:23:36 UTC 2004
On Tue, Oct 26, 2004 at 02:39:14PM -0600, Steve Holle wrote:
> I'm getting a malloc failure and I'm wondering if anyone has a method
> for determining heap usage in RTEMS. How can I determine what my
> margins are?
if you have compiled RTEMS libraries with -DRTEMS_DEBUG, malloc will
maintain statistics. #include <libcsupport.h>, and malloc_dump() will
print malloc's heap statistics for you.
example usage can be found in c/src/tests/frye/libcleak and
c/src/tests/libtests/malloctest .
the following gdb macro might also be of use. give it an argument of 0
for a summary, or 1 to explicitly list the regions.
define rtems-mallocheap-walk
printf "walking the heap:\n"
set $heapstart = ((Region_Control *)_Region_Information->local_table[RTEMS_Malloc_Heap&0xffff])->Memory->start
set $currentblock = $heapstart
set $used = 0
set $numused = 0
set $free = 0
set $numfree = 0
while $currentblock->front_flag != 1
if $currentblock->front_flag & 1
if $arg0 != 0
printf "USED: %d\n", $currentblock->front_flag & ~1
else
printf "*"
end
set $used = $used + $currentblock->front_flag & ~1
set $numused = $numused + 1
else
if $arg0 != 0
printf "FREE: %d\n", $currentblock->front_flag & ~1
else
printf "."
end
set $free = $free + $currentblock->front_flag & ~1
set $numfree = $numfree + 1
end
set $currentblock = (Heap_Block *)((char *)$currentblock + ($currentblock->front_flag&~1))
end
if $arg0 == 0
printf "\n"
end
printf "TOTAL: %d (%d)\tUSED: %d (%d) \tFREE: %d (%d)\n", \
$used + $free, $numused + $numfree, \
$used, $numused, \
$free, $numfree
end
--
Aaron J. Grier | Frye Electronics, Tigard, OR | aaron at frye.com
"Note that many bands' backline amps produce levels exceeding OSHA
standards for industrial facilities. Yet this is considered normal
working conditions for musicians. That's showbiz." -- Scott Dorsey
More information about the users
mailing list