Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #13816 > unrolled thread

Memory footprint of a structure of structures

Started byJean-Michel Hautbois <jhautbois@gmail.com>
First post2011-11-23 03:00 -0800
Last post2011-11-27 10:17 +0000
Articles 6 on this page of 26 — 11 participants

Back to article view | Back to comp.lang.c


Contents

  Memory footprint of a structure of structures Jean-Michel Hautbois <jhautbois@gmail.com> - 2011-11-23 03:00 -0800
    Re: Memory footprint of a structure of structures James Kuyper <jameskuyper@verizon.net> - 2011-11-23 06:33 -0500
      Re: Memory footprint of a structure of structures Philipp Klaus Krause <pkk@spth.de> - 2011-11-23 19:58 +0100
        Re: Memory footprint of a structure of structures James Kuyper <jameskuyper@verizon.net> - 2011-11-23 15:41 -0500
          Re: Memory footprint of a structure of structures Ark <akhasin@macroexpressions.com> - 2011-11-23 23:59 -0500
            Re: Memory footprint of a structure of structures "Philip Lantz" <prl@canterey.us> - 2011-11-23 22:01 -0800
            Re: Memory footprint of a structure of structures James Kuyper <jameskuyper@verizon.net> - 2011-11-24 11:56 -0500
          Re: Memory footprint of a structure of structures Philipp Klaus Krause <pkk@spth.de> - 2011-11-24 10:06 +0100
            Re: Memory footprint of a structure of structures James Kuyper <jameskuyper@verizon.net> - 2011-11-24 12:00 -0500
              Re: Memory footprint of a structure of structures Jean-Michel Hautbois <jhautbois@gmail.com> - 2011-11-25 03:01 -0800
                Re: Memory footprint of a structure of structures Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-25 12:52 +0000
                  Re: Memory footprint of a structure of structures "BartC" <bc@freeuk.com> - 2011-11-25 13:29 +0000
                Re: Memory footprint of a structure of structures James Kuyper <jameskuyper@verizon.net> - 2011-11-25 15:06 -0500
                  Re: Memory footprint of a structure of structures Ark <akhasin@macroexpressions.com> - 2011-11-27 00:41 -0500
    Re: Memory footprint of a structure of structures Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-23 17:37 +0000
    Re: Memory footprint of a structure of structures Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-23 22:46 +0100
      Re: Memory footprint of a structure of structures Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-23 22:55 +0100
        Re: Memory footprint of a structure of structures Ark <akhasin@macroexpressions.com> - 2011-11-24 00:04 -0500
      Re: Memory footprint of a structure of structures Jean-Michel Hautbois <jhautbois@gmail.com> - 2011-11-24 00:39 -0800
      Re: Memory footprint of a structure of structures Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-24 10:34 +0000
        Re: Memory footprint of a structure of structures "BartC" <bc@freeuk.com> - 2011-11-24 12:18 +0000
          Re: Memory footprint of a structure of structures Jean-Michel Hautbois <jhautbois@gmail.com> - 2011-11-24 07:11 -0800
            Re: Memory footprint of a structure of structures jgk@panix.com (Joe keane) - 2011-11-25 22:08 +0000
              Re: Memory footprint of a structure of structures Ian Collins <ian-news@hotmail.com> - 2011-11-26 11:37 +1300
                Re: Memory footprint of a structure of structures jgk@panix.com (Joe keane) - 2011-11-27 23:20 +0000
          Re: Memory footprint of a structure of structures Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-27 10:17 +0000

Page 2 of 2 — ← Prev page 1 [2]


#13852

From"BartC" <bc@freeuk.com>
Date2011-11-24 12:18 +0000
Message-ID<jalcn6$o8j$1@dont-email.me>
In reply to#13851

"Jorgen Grahn" <grahn+nntp@snipabacken.se> wrote in message 
news:slrnjcs7d1.1bk.grahn+nntp@frailea.sa.invalid...
> On Wed, 2011-11-23, Vincenzo Mercuri wrote:

>> I'm confused, but the fact that you are not interested in memory
>> dynamically allocated (i.e. "malloced") makes me think that you only
>> need to know the total size of the structures.
>
> It's quite common IME to want to get a feel for the size of structs.
> If the nesting level is deep and you didn't write the code yourself,
> it can be time-consuming and error-prone to figure out manually if
> something takes 1000 bytes or 50,000 bytes ...

You write a one-line program, or one-line extension, to simply print the 
static size, of the top-most struct.

But OP wants the sizes to be displayed in a tree-format, without the effort 
of writing, and having to maintain in parallel, a long sequence of 
printf/sizeof lines.

-- 
bartc 

[toc] | [prev] | [next] | [standalone]


#13858

FromJean-Michel Hautbois <jhautbois@gmail.com>
Date2011-11-24 07:11 -0800
Message-ID<c8faa4fa-97c2-41dc-aafd-28db8a6364ad@14g2000yqo.googlegroups.com>
In reply to#13852
On 24 nov, 13:18, "BartC" <b...@freeuk.com> wrote:
> "Jorgen Grahn" <grahn+n...@snipabacken.se> wrote in message
>
> news:slrnjcs7d1.1bk.grahn+nntp@frailea.sa.invalid...
>
> > On Wed, 2011-11-23, Vincenzo Mercuri wrote:
> >> I'm confused, but the fact that you are not interested in memory
> >> dynamically allocated (i.e. "malloced") makes me think that you only
> >> need to know the total size of the structures.
>
> > It's quite common IME to want to get a feel for the size of structs.
> > If the nesting level is deep and you didn't write the code yourself,
> > it can be time-consuming and error-prone to figure out manually if
> > something takes 1000 bytes or 50,000 bytes ...
>
> You write a one-line program, or one-line extension, to simply print the
> static size, of the top-most struct.
>
> But OP wants the sizes to be displayed in a tree-format, without the effort
> of writing, and having to maintain in parallel, a long sequence of
> printf/sizeof lines.
>
> --
> bartc

Exactly :) And AFAIK there is no real solution with C language for
that.
So, the only thing I can see is GCC related, or a parsing script using
sed/awk for instance...
If anyone has some tips I am interested :).

JM

[toc] | [prev] | [next] | [standalone]


#13897

Fromjgk@panix.com (Joe keane)
Date2011-11-25 22:08 +0000
Message-ID<jap3k4$9vm$1@reader1.panix.com>
In reply to#13858
"nm" gives you some help although not what OP asked for.

"gprof" gives you some help although not what OP asked for.

You can try something like:

    #define malloc(SZ) ((SZ) < 512 ? malloc_some_small_thing(SZ) :
	(SZ) < 8192 ? malloc_some_medium_thing(SZ) :
	malloc_some_big_thing(SZ))

[toc] | [prev] | [next] | [standalone]


#13898

FromIan Collins <ian-news@hotmail.com>
Date2011-11-26 11:37 +1300
Message-ID<9jajkuF4d0U10@mid.individual.net>
In reply to#13897
On 11/26/11 11:08 AM, Joe keane wrote:
> "nm" gives you some help although not what OP asked for.
>
> "gprof" gives you some help although not what OP asked for.

Which OP?

> You can try something like:
>
>      #define malloc(SZ) ((SZ)<  512 ? malloc_some_small_thing(SZ) :
> 	(SZ)<  8192 ? malloc_some_medium_thing(SZ) :
> 	malloc_some_big_thing(SZ))

Which will fail as soon as you include <stdlib.h>

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#13985

Fromjgk@panix.com (Joe keane)
Date2011-11-27 23:20 +0000
Message-ID<jaugkg$dpq$1@reader1.panix.com>
In reply to#13898
In article <9jajkuF4d0U10@mid.individual.net>,
Ian Collins  <ian-news@hotmail.com> wrote:
>Which will fail as soon as you include <stdlib.h>

No, i found it useful, maybe someone else will find it useful as well.

Of course it is extra-legal; so is using "gprof" since there is no such
thing in the standard.

[toc] | [prev] | [next] | [standalone]


#13960

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2011-11-27 10:17 +0000
Message-ID<slrnjd43hl.1bk.grahn+nntp@frailea.sa.invalid>
In reply to#13852
On Thu, 2011-11-24, BartC wrote:
>
>
> "Jorgen Grahn" <grahn+nntp@snipabacken.se> wrote in message 
> news:slrnjcs7d1.1bk.grahn+nntp@frailea.sa.invalid...
>> On Wed, 2011-11-23, Vincenzo Mercuri wrote:
>
>>> I'm confused, but the fact that you are not interested in memory
>>> dynamically allocated (i.e. "malloced") makes me think that you only
>>> need to know the total size of the structures.
>>
>> It's quite common IME to want to get a feel for the size of structs.
>> If the nesting level is deep and you didn't write the code yourself,
>> it can be time-consuming and error-prone to figure out manually if
>> something takes 1000 bytes or 50,000 bytes ...
>
> You write a one-line program, or one-line extension, to simply print the 
> static size, of the top-most struct.

I'm often cross-compiling and/or doing experimental changes to the
data structures which break other parts of the code ... so that
solution isn't the first I think of.

> But OP wants the sizes to be displayed in a tree-format, without the effort 
> of writing, and having to maintain in parallel, a long sequence of 
> printf/sizeof lines.

Of course he does. I want that too.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.c


csiph-web