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


Groups > comp.lang.c++ > #10618

Re: Small question with respect to scope and performace

From Richard Damon <news.x.richarddamon@xoxy.net>
Newsgroups comp.lang.c++
Subject Re: Small question with respect to scope and performace
Date 2011-09-30 19:22 -0400
Organization A noiseless patient Spider
Message-ID <j65j00$nas$1@dont-email.me> (permalink)
References <27725376.29.1317422561029.JavaMail.geo-discussion-forums@yqbu18>

Show all headers | View raw


On 9/30/11 6:42 PM, sravanreddy001 wrote:
> Hi,
>
> I have small doubt.
>
> There are two functions.
> 1) stores lot of data.. atleast 100 MB
> 2) another doesn't use above data.
>
> so, if 2 is called from 1.
> where the contents of 1 be moved to stack? and 2. is called?
>
> In that case, does maintaining the data as global values, will reduce that overhead? (Security of data can be managed and not an issue)
>
> Thanks,
> Sravan.

If 1 stores its data on the stack, it will be there once the function 
creates it, and not "moved" there when 2 is called, so there is no 
overhead there.

If 1 stores its data else where, it won't be moved there either.


To be pedantic, actually this isn't the way the standard says it, 
because the standard never refers to "the stack". Typical implementation 
though is to place variables of storage class "auto" (as opposed to 
global, static or objects created on the heap) on the stack.

100 MB of data is large to be all "on the stack" (but possible), but my 
guess is that much of this data is apt to be in containers, where the 
control structure for the container may be on the stack, but most of the 
data will be on the heap.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Small question with respect to scope and performace sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-30 15:42 -0700
  Re: Small question with respect to scope and performace Richard Damon <news.x.richarddamon@xoxy.net> - 2011-09-30 19:22 -0400
  Re: Small question with respect to scope and performace Noah Roberts <roberts.noah@gmail.com> - 2011-09-30 15:51 -0700
  Re: Small question with respect to scope and performace sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-30 19:31 -0700
    Re: Small question with respect to scope and performace Richard Damon <news.x.richarddamon@xoxy.net> - 2011-09-30 23:14 -0400

csiph-web