cin >> z;
cout << z;
for (int c=0;c<z;c++ )
/*sir i want here to create variable type long (ac)again and again
,a1,a2,a3..... but only one address variable created i wana see how
much memoryy decrease with thousands of long variable*/
cout << "p" << '\n' << ∾
On 1/13/2013 6:10 AM, Juha Nieminen wrote:
> email@example.com wrote:
>> long ac;
>> /*sir i want here to create variable type long (ac)again and again
>> ,a1,a2,a3..... but only one address variable created i wana see how
>> much memoryy decrease with thousands of long variable*/
> And why, exactly?
To verify an assumption, perhaps.
> If you just declare a variable but never use, there's a good chance that
> the compiler will optimize it away, so it will not take any memory.
If it's a member of a class, or an element of an array, this will not
> And even if it did, why do it the hard way? The amount of bytes that a
> variable of type 'long' takes is "sizeof(long)". Just multiply that by
> the amount of variables, and you get how much memory they require
> (assuming that they are actually used for something.)
It's a funny thing, memory, isn't it? You allocate an array of five
thousand longs, *and* write code to use it, and suddenly the process
memory grows by more than 5000*sizeof(long). Is it linear? Is it
logarithmic?... Somebody might want to find the pattern, *assuming*
there is one. And then they might want to try to figure out the
reason... They fancy themselves a researcher, so let them. Perhaps
it's in vain to try to tell them not to do it because there is some
theoretical dependency between the number of longs allocated and the
amount of memory used. So? They probably want empirical evidence.
I do not respond to top-posted replies, please don't ask
|All times are GMT. The time now is 03:07 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.