Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > programing

Reply
Thread Tools

programing

 
 
mc110403106@gmail.com
Guest
Posts: n/a
 
      01-13-2013
#include <iostream.h>
main()
{
long z,i,b;
cin >> z;
cout << z;
for (i=0;i<z;i++)
{
for (int c=0;c<z;c++ )
{
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*/

cout << "p" << '\n' << &ac;
}

}

}
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-13-2013
On 1/13/2013 6:10 AM, Juha Nieminen wrote:
> http://www.velocityreviews.com/forums/(E-Mail Removed) 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
hold necessarily.

> 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.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me please : WepKey Changer Programing (Windows) Truty Wireless Networking 2 03-29-2006 10:52 PM
Simple asp.net programing question Support ASP .Net 5 01-27-2006 02:25 PM
Some Programing Required Murray J Java 5 12-24-2004 06:00 PM
structural programing valli VHDL 2 11-15-2004 02:12 PM
First try at IOS programing mmm00k@yahoo.com Cisco 0 11-18-2003 09:43 PM



Advertisments