Memory region tracking similar to malloc_stats?
Phil Torre
ptorre at zetron.com
Tue Sep 11 19:57:29 UTC 2001
Hmm. Grepping my source tree, I don't have malloc_free_space,
rtems_region_get_information, _Heap_Get_information, or
Heap_Information_block. Is this the price I pay for loitering
back at 4.5.0? :)
(If so, can I get the required code from a snapshot, or has the
heap code changed too much?)
Many thanks...
On Tue, Sep 11, 2001 at 11:07:43AM -0500, Joel Sherrill wrote:
> Phil Torre wrote:
> >
> > Is there a simple way to access the current amount of space remaining
> > in a region? Something like malloc_stats would be great, but I don't
> > actually need the allocation history so much as the current free
> > space (so as to watch for get_segment/return_segment leaks).
> > It looks like the right thing to do is to walk the heap blocks like
> > _Heap_Allocate() does, but I'll save myself some fumbling around if
> > this work has already been done. Thanks...
>
> How about this routine? :)
>
>
> /*
> * Find amount of free heap remaining
> */
>
> size_t malloc_free_space( void )
>
> It is based on the rtems_region_get_information()
> call. It can return the following info:
>
> /*
> * Information block returned by _Heap_Get_information
> */
>
> typedef struct {
> unsigned32 free_blocks;
> unsigned32 free_size;
> unsigned32 used_blocks;
> unsigned32 used_size;
> } Heap_Information_block;
--
=====================================================================
Phil Torre phone: 425-820-6363 x234
Design Engineer email: ptorre at zetron.com
Switching Systems Group fax: 425-820-7031
Zetron, Inc. web: http://www.zetron.com
More information about the users
mailing list