This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static variables, the stack, the heap, and speed


Sorry, I meant using automatic over static variables.

On 7/24/06, Noel Yap <noel.yap@gmail.com> wrote:
Can you give a link to the article please?  Unless I'm missing
something, what the article alleges doesn't make any sense.  Static
duration variables aren't stored in the heap but rather, in the data
segment (not sure if this is proper terminology).

IIRC, heap access is the slowest and data access is the fastest, but
unless there's a strong rationale for coding with this in mind, I'd
stick to using automatic (aka stack) variables.

Noel

On 7/24/06, Bill McEnaney <bill@rkirkpat.net> wrote:
> Hi, Folks,
>
> I've read an article that says that since program get a static
> variable's storage from the heap, the program can access static
> variables faster than it can access automatic ones.  Is that true?
>
> Thanks.
>
> Bill
> ________________________________________________________________
> "Pro-choice?"  Then click here.
> http://cathinsight.com/morality/saying.htm
>
> "Men must look for the peace of Christ in the Kingdom of Christ... When
> once men recognize, both in private and in public life, that Christ is
> King, society will at last receive the great blessings of real liberty,
> well-ordered discipline, peace and harmony."  Pope Pius XI
>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]