public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] anybody use mallinfo?
@ 2004-08-18  0:07 Richard.von.Lehe
  0 siblings, 0 replies; 3+ messages in thread
From: Richard.von.Lehe @ 2004-08-18  0:07 UTC (permalink / raw)
  To: andrew; +Cc: ecos-discuss

That was it.

-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch]
Sent: Tuesday, August 17, 2004 5:57 PM
To: von Lehe, Richard H
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] anybody use mallinfo?


On Tue, Aug 17, 2004 at 05:48:32PM -0500, Richard.von.Lehe@gd-ais.com wrote:
> Hi All,
> 

> I thought I would experiment to see if mallinfo is usable and maybe
> use it to get an idea of how much heap we're using.  I created a
> simple test program that spits out the mallinfo struct before a
> 'new', after a 'new', and after a 'delete'.  I thought that the
> pre-new and post-delete values would be the same, but it didn't turn
> out that way.

> The uordblocks increases by 1008 after 'new'ing 1000 chars.  I would
> have thought it should be 1000, but whatever. 

The heap code needs some overhead to keep track of allocated
memory. That is what the 8 bytes are for.

> Then, it doesn't
> decrease after the 'delete []' call.  Does all this just mean that
> the implementation of mallinfo is not complete and I should stay
> away from it or am I misunderstanding something?

You might be missing CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] anybody use mallinfo?
  2004-08-17 22:48 Richard.von.Lehe
@ 2004-08-17 22:57 ` Andrew Lunn
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2004-08-17 22:57 UTC (permalink / raw)
  To: Richard.von.Lehe; +Cc: ecos-discuss

On Tue, Aug 17, 2004 at 05:48:32PM -0500, Richard.von.Lehe@gd-ais.com wrote:
> Hi All,
> 

> I thought I would experiment to see if mallinfo is usable and maybe
> use it to get an idea of how much heap we're using.  I created a
> simple test program that spits out the mallinfo struct before a
> 'new', after a 'new', and after a 'delete'.  I thought that the
> pre-new and post-delete values would be the same, but it didn't turn
> out that way.

> The uordblocks increases by 1008 after 'new'ing 1000 chars.  I would
> have thought it should be 1000, but whatever. 

The heap code needs some overhead to keep track of allocated
memory. That is what the 8 bytes are for.

> Then, it doesn't
> decrease after the 'delete []' call.  Does all this just mean that
> the implementation of mallinfo is not complete and I should stay
> away from it or am I misunderstanding something?

You might be missing CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ECOS] anybody use mallinfo?
@ 2004-08-17 22:48 Richard.von.Lehe
  2004-08-17 22:57 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Richard.von.Lehe @ 2004-08-17 22:48 UTC (permalink / raw)
  To: ecos-discuss

Hi All,

I thought I would experiment to see if mallinfo is usable and maybe use it to get an idea of how much heap we're using.  I created a simple test program that spits out the mallinfo struct before a 'new', after a 'new', and after a 'delete'.  I thought that the pre-new and post-delete values would be the same, but it didn't turn out that way.

The uordblocks increases by 1008 after 'new'ing 1000 chars.  I would have thought it should be 1000, but whatever.  Then, it doesn't decrease after the 'delete []' call.  Does all this just mean that the implementation of mallinfo is not complete and I should stay away from it or am I misunderstanding something?

This is on the A&M Rattler boards if that makes any difference.

Thanks!
Rich

Here's the program and output:


<---- CODE ----->
int main(int argc, char* argv[])
{
  struct mallinfo minfo;
  char* pChar;

  minfo = mallinfo(); 
  diag_printf("arena:%d ordblks:%d smblks:%d hblks:%d hblkhd:%d\n", minfo.arena, 
    minfo.ordblks, minfo.smblks, minfo.hblks, minfo.hblkhd);
  diag_printf("usmblks:%d fsmblks:%d uordblks:%d fordblks:%d keepcost: %d\n",   
    minfo.usmblks, minfo.fsmblks, minfo.uordblks, minfo.fordblks,
    minfo.keepcost); 

  pChar = new char[1000];

  strcpy(pChar, "The quick brown fox jumps over the lazy dog.");

  minfo = mallinfo(); 
  diag_printf("arena:%d ordblks:%d smblks:%d hblks:%d hblkhd:%d\n", minfo.arena, 
    minfo.ordblks, minfo.smblks, minfo.hblks, minfo.hblkhd);
  diag_printf("usmblks:%d fsmblks:%d uordblks:%d fordblks:%d keepcost: %d\n",   
    minfo.usmblks, minfo.fsmblks, minfo.uordblks, minfo.fordblks,
    minfo.keepcost); 
  
  delete [] pChar;

  minfo = mallinfo(); 
  diag_printf("arena:%d ordblks:%d smblks:%d hblks:%d hblkhd:%d\n", minfo.arena, 
    minfo.ordblks, minfo.smblks, minfo.hblks, minfo.hblkhd);
  diag_printf("usmblks:%d fsmblks:%d uordblks:%d fordblks:%d keepcost: %d\n",   
    minfo.usmblks, minfo.fsmblks, minfo.uordblks, minfo.fordblks,
    minfo.keepcost); 
  
  return 0;
}
<----- end code ----->


Output:
arena:14955096 ordblks:1 smblks:0 hblks:0 hblkhd:0
usmblks:0 fsmblks:0 uordblks:528 fordblks:14954548 keepcost: 0

arena:14955096 ordblks:1 smblks:0 hblks:0 hblkhd:0
usmblks:0 fsmblks:0 uordblks:1536 fordblks:14953540 keepcost: 0

arena:14955096 ordblks:1 smblks:0 hblks:0 hblkhd:0
usmblks:0 fsmblks:0 uordblks:1536 fordblks:14953540 keepcost: 0


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-18  0:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-18  0:07 [ECOS] anybody use mallinfo? Richard.von.Lehe
  -- strict thread matches above, loose matches on Subject: below --
2004-08-17 22:48 Richard.von.Lehe
2004-08-17 22:57 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).