By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,489 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,489 IT Pros & Developers. It's quick & easy.

A memory question

P: n/a
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?
Thanks a lot!

Nov 16 '05 #1
Share this Question
Share on Google+
36 Replies


P: n/a
po***********@gmail.com wrote:
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?
Thanks a lot!

It's obviously due to what you're doing on line 42.

[Seriously, though, how would *anyone* know -- or even hazard a
reasonable guess -- without some relevant information?]

HTH,
--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Nov 16 '05 #2

P: n/a
po***********@gmail.com wrote:
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?


You are using that much.
You are wasting part of it.

Your request is definitely off-topic in comp.lang.c
For questions about algorithms and data structures, consider
asking in comp.programming.

-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 16 '05 #3

P: n/a
po***********@gmail.com wrote:

Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?


You have an error on line 42.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 16 '05 #4

P: n/a
Kenneth Brody wrote:
po***********@gmail.com wrote:
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?

You have an error on line 42.

So we agree. We must be right. Or not. ;-)

--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Nov 16 '05 #5

P: n/a
Sorry could you please explain more detailedly?
What's line 42?
Thanks a lot!

Nov 16 '05 #6

P: n/a
po***********@gmail.com writes:
Sorry could you please explain more detailedly?
What's line 42?
Thanks a lot!


Assuming you're serious ...

"line 42" is a wild guess about where the problem in your program
might be. It's a joke. Since you've given us absolutely no useful
information that would help us answer your question, that's the best
we can do.

And please don't assume we can see the article to which you're
replying. You need to provide some context. Google makes it
gratuitously difficult to do this properly, but there is a workaround
(that's been posted here over 1000 times).

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

And please complain to Google about their broken interface. They can
do whatever they like with their own private non-Usenet groups, but
they are damaging Usenet, something that's been around decades longer
than they have.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 16 '05 #7

P: n/a
po***********@gmail.com writes:
Sorry could you please explain more detailedly?
What's line 42?


It means "we don't know anything about your program or your
system, so we can't tell you why it's using a lot of memory."
--
"For those who want to translate C to Pascal, it may be that a lobotomy
serves your needs better." --M. Ambuhl

"Here are the steps to create a C-to-Turbo-Pascal translator..." --H. Schildt
Nov 16 '05 #8

P: n/a


po***********@gmail.com wrote On 11/16/05 16:22,:
Sorry could you please explain more detailedly?
What's line 42?


It's the successor of the successor of the successor of
the successor of the successor of the successor of the successor
of the successor of the successor of the successor of the
successor of the successor of the successor of the successor
of the successor of the successor of the successor of the
successor of the successor of the successor of the successor
of the successor of the successor of the successor of the
successor of the successor of the successor of the successor
of the successor of the successor of the successor of the
successor of the successor of the successor of the successor
of the successor of the successor of the successor of the
successor of the successor of the successor of line 1.

And, to anticipate your follow-up question: line 1 is
the first line you did not show us.

"Doctor, I don't feel so good. What's wrong?"

"Based on the information you've provided, I conclude
that there's something wrong with your body. Pay the
receptionist on your way out. Next!"

--
Er*********@sun.com

Nov 16 '05 #9

P: n/a
On 16 Nov 2005 11:48:23 -0800, in comp.lang.c ,
po***********@gmail.com wrote:
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?


30M isn't a lot. When your programme takes 8GB, then you can
complain...

Seriously tho, who knows? You've not said anything at all about what
your programme does., or shown any code fragments.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 17 '05 #10

P: n/a
On 16 Nov 2005 13:22:33 -0800, in comp.lang.c ,
po***********@gmail.com wrote:
Sorry could you please explain more detailedly?
What's line 42?


Please read the Hitchikers Guide to the Galaxy. The meaning of "42"
will then become clear.

Also, please read my sig
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 17 '05 #11

P: n/a

<po***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Sorry could you please explain more detailedly?
What's line 42?


Load your program into a text editor. Scroll
to line 42. Look at it.

-Mike
Nov 17 '05 #12

P: n/a

po***********@gmail.com wrote:
Sorry could you please explain more detailedly?
What's line 42?
Thanks a lot!


may be this can help.
http://en.wikipedia.org/wiki/The_Ans...and_Everything

Nov 17 '05 #13

P: n/a

po***********@gmail.com schrieb:
Hello it takes about 30M memory to run my program.
How do you know that?
Can anyone give me some suggestions on why it costs so much memory?


Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.

Nov 17 '05 #14

P: n/a
Ingo Menger wrote:

po***********@gmail.com schrieb:
Hello it takes about 30M memory to run my program.


How do you know that?
Can anyone give me some suggestions on why it costs so much memory?


Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


Obviously, your furnace has an error on line 42. :-)

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Nov 17 '05 #15

P: n/a
<po***********@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?
Thanks a lot!


I'm having the same problem... but my code doesn't have 42 lines so I'm not
sure what's wrong!

#include <stdio.h>
void main(void)
{
char buf[31457280] = "hello world";
puts(buf);
return 0;
}

Hmm... maybe they meant the problem is on lines 4 AND 2...
void main(void)
- just like they have it in my textbook, looks good.
char buf[31457280];
- more than enough space to hold that little string.
Oh well, I guess I'll blame my compiler... it is a pig ;)
Nov 17 '05 #16

P: n/a

"Ingo Menger" <qu*********@consultant.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

po***********@gmail.com schrieb:
Hello it takes about 30M memory to run my program.


How do you know that?
Can anyone give me some suggestions on why it costs so much memory?


Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


Your gallons are too small.

-Mike
Nov 17 '05 #17

P: n/a
"Ingo Menger" <qu*********@consultant.com> writes:
po***********@gmail.com schrieb:
Hello it takes about 30M memory to run my program.


How do you know that?
Can anyone give me some suggestions on why it costs so much memory?


Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


Probably because galloons (narrow bands or braids used as trimming and
commonly made of lace, metallic thread, or embroidery) aren't very
efficient containers for heating oil.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 17 '05 #18

P: n/a
Ingo Menger wrote:
Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


You live in your car?

Nov 17 '05 #19

P: n/a
Mark B said:
<po***********@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?
Thanks a lot!
I'm having the same problem... but my code doesn't have 42 lines so I'm
not sure what's wrong!

#include <stdio.h>
void main(void)
{
char buf[31457280] = "hello world";
puts(buf);
return 0;
}

Hmm... maybe they meant the problem is on lines 4 AND 2...


Yeah.
void main(void)
- just like they have it in my textbook, looks good.
Your faith in your textbook is touching. But wait...
char buf[31457280];
- more than enough space to hold that little string.
....that's a very curious number which, I am convinced, was carefully chosen
for a certain property it has. If I'm right, then I would guess that your
main error was deliberate, too.
Oh well, I guess I'll blame my compiler... it is a pig ;)


Could I suggest gcc instead? Pigs are not particularly celebrated for their
ability to produce particularly efficient object code.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Nov 18 '05 #20

P: n/a

Keith Thompson schrieb:
"Ingo Menger" <qu*********@consultant.com> writes:
po***********@gmail.com schrieb:
Hello it takes about 30M memory to run my program.


How do you know that?
Can anyone give me some suggestions on why it costs so much memory?


Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


Probably because galloons (narrow bands or braids used as trimming and
commonly made of lace, metallic thread, or embroidery) aren't very
efficient containers for heating oil.


Okay. :)
Actually, I measure heating oil in liters.

Nov 18 '05 #21

P: n/a

Old Wolf schrieb:
Ingo Menger wrote:
Only if you can give me a suggestion on why I need around 1000 galloons
of heating oil per annum to heat my home.


You live in your car?


No. BTW, here in germany, it is against the law to drive your diesel
car with heating oil. Diesel fuel, which is chemically the same, costs
twice as much due to fuel taxes.

Nov 18 '05 #22

P: n/a

<po***********@gmail.com> wrote
Hello it takes about 30M memory to run my program.
Can anyone give me some suggestions on why it costs so much memory?
Thanks a lot!

Firstly, add up your allocations and stack usage.
If you find they come to around 30Mb, then there's your answer.
Sometimes if you allocate a huge number of tiny structures the compiler will
pad them out to the nearest kilobyte, gobbling lots of memory.

Then look at the library functions you are calling. How much memory does
"Hello world" take on your platform? If "hello world" is small, cut the
program down to "hello world" and then gradually comment functionality back
in. That should tell you where the memory is going.


Nov 19 '05 #23

P: n/a

"Richard Heathfield" <in*****@invalid.invalid> wrote
#include <stdio.h>
void main(void)
{
char buf[31457280] = "hello world";
puts(buf);
return 0;
}

...that's a very curious number which, I am convinced, was carefully
chosen
for a certain property it has. If I'm right, then I would guess that your
main error was deliberate, too.
Oh well, I guess I'll blame my compiler... it is a pig ;)


Could I suggest gcc instead? Pigs are not particularly celebrated for
their
ability to produce particularly efficient object code.

If it's a pig of a compiler it ought to be able to chomp up pies quite
nicely.
Nov 19 '05 #24

P: n/a
Mark McIntyre wrote
(in article <n7********************************@4ax.com>):
On 16 Nov 2005 13:22:33 -0800, in comp.lang.c ,
po***********@gmail.com wrote:
Sorry could you please explain more detailedly?
What's line 42?


Please read the Hitchikers Guide to the Galaxy. The meaning of "42"
will then become clear.


Actually, it won't as I recall. I thought you had to read the
sequel to find out its meaning??? It's been a number of years,
perhaps I have it wrong.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Nov 19 '05 #25

P: n/a
Randy Howard wrote:
Mark McIntyre wrote
(in article <n7********************************@4ax.com>):

On 16 Nov 2005 13:22:33 -0800, in comp.lang.c ,
po***********@gmail.com wrote:

Sorry could you please explain more detailedly?
What's line 42?


Please read the Hitchikers Guide to the Galaxy. The meaning of "42"
will then become clear.

Actually, it won't as I recall. I thought you had to read the
sequel to find out its meaning??? It's been a number of years,
perhaps I have it wrong.

I think I read that after several years, the computer calculated that 42
was indeed the answer, but that the question was flawed. Much too
esoteric for me anymore.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 19 '05 #26

P: n/a
On Sat, 19 Nov 2005 11:10:52 -0500, in comp.lang.c , Joe Wright
<jw*****@comcast.net> wrote:
Randy Howard wrote:
Mark McIntyre wrote
Please read the Hitchikers Guide to the Galaxy. The meaning of "42"
will then become clear.


Actually, it won't as I recall.

I think I read that after several years, the computer calculated that 42
was indeed the answer, but that the question was flawed.


Thats about the size of it...

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 19 '05 #27

P: n/a
Joe Wright <jw*****@comcast.net> schrieb:
I think I read that after several ...
.... million ...
.. years, the computer calculated that 42
was indeed the answer ...
.... to the question of 'life, the universe and everything',
but that the question was flawed. Much too
esoteric for me anymore.


The computer (*Deep Thought*) that had calculated the answer had
warned its creators that his answer would not please them,
because they were not really aware of the question.

But he had already constructed a massively greater, faster,
better computer to calculate the question to this answer.
This computer was - or is, for that matter - called:

'*The Earth*'

Us mere humans were/are/have been/will be an integral part of
the organic matrix of that computer, which, by the way, was run
by the most intelligent species on earth; no, not humans nor
dolphins, but mice. Unfortunately, shortly before the completion
of the calculation, earth was (will have been destroyed - it's
not easy to talk of the future as something from the past - look
up temporal grammar in the Hitchhiker's Guide to the Galaxy)
destroyed to make place for an interplanetary hyperspace-
express-route by the Vogons.

Know where your towel is and:
Don't panic!

hth, Markus
Nov 19 '05 #28

P: n/a
Markus Becker <ye*******@web.de> wrote:
# Joe Wright <jw*****@comcast.net> schrieb:
#
# > I think I read that after several ...
#
# ... million ...
#
# > .. years, the computer calculated that 42
# > was indeed the answer ...
#
# ... to the question of 'life, the universe and everything',
#
# > but that the question was flawed. Much too
# > esoteric for me anymore.
#
# The computer (*Deep Thought*) that had calculated the answer had
# warned its creators that his answer would not please them,
# because they were not really aware of the question.

9x6 = 42 in radix 13.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Don't say anything. Especially you.
Nov 20 '05 #29

P: n/a
SM Ryan wrote:

Markus Becker <ye*******@web.de> wrote:
# Joe Wright <jw*****@comcast.net> schrieb:
#
# > I think I read that after several ...
#
# ... million ...
#
# > .. years, the computer calculated that 42
# > was indeed the answer ...
#
# ... to the question of 'life, the universe and everything',
#
# > but that the question was flawed. Much too
# > esoteric for me anymore.
#
# The computer (*Deep Thought*) that had calculated the answer had
# warned its creators that his answer would not please them,
# because they were not really aware of the question.

9x6 = 42 in radix 13.


"Nobody writes jokes in base 13" -- Douglas Adams

--
pete
Nov 20 '05 #30

P: n/a
[ stupid '#' quoting character fixed ]
pete <pf*****@mindspring.com> writes:
SM Ryan wrote:
Markus Becker <ye*******@web.de> wrote:
> Joe Wright <jw*****@comcast.net> schrieb:
>
> > I think I read that after several ...
>
> ... million ...
>
> > .. years, the computer calculated that 42
> > was indeed the answer ...
>
> ... to the question of 'life, the universe and everything',
>
> > but that the question was flawed. Much too
> > esoteric for me anymore.
>
> The computer (*Deep Thought*) that had calculated the answer had
> warned its creators that his answer would not please them,
> because they were not really aware of the question.


9x6 = 42 in radix 13.


"Nobody writes jokes in base 13" -- Douglas Adams


#include <stdio.h>

#define SIX 1+5
#define NINE 8+1

int main(void)
{
printf("%d * %d = %d\n", SIX, NINE, SIX * NINE);
return 0;
}

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 20 '05 #31

P: n/a
]///\
> The computer (*Deep Thought*) that had calculated the answer had
> warned its creators that his answer would not please them,
> because they were not really aware of the question.

9x6 = 42 in radix 13.


"Nobody writes jokes in base 13" -- Douglas Adams


#include <stdio.h>

#define SIX 1+5
#define NINE 8+1

int main(void)
{
printf("%d * %d = %d\n", SIX, NINE, SIX * NINE);
return 0;
}


Ooh! Shiny! And back (sort of) on topic for CLC.

I wonder how long before a newbie posts "how does that work"?

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 20 '05 #32

P: n/a
>>>>> The computer (*Deep Thought*) that had calculated the answer had
> warned its creators that his answer would not please them,
> because they were not really aware of the question.
Keith Thompson wrote:
int main(void)
{
printf("%d * %d = %d\n", SIX, NINE, SIX * NINE);
return 0;
}

Kenneth Brody wrote: I wonder how long before a newbie posts "how does that work"?


The computer took 7.5 million years to compute its answer,
and it was built 17.5 million years ago.

According to Moore's Law, the same calculation could be done in
a fraction of a second today. This program is clearly repeating
Deep Thought's work, and since DT was such a great computer,
getting the same answer.

Nov 20 '05 #33

P: n/a

Kenneth Brody wrote:
I wonder how long before a newbie posts "how does that work"?


may be 42 years, or 42 days, or 42 hours or ...

haroon

Nov 21 '05 #34

P: n/a
"Randy Howard" <ra*********@FOOverizonBAR.net> wrote in message
news:00*****************************@news.verizon. net...
Mark McIntyre wrote
(in article <n7********************************@4ax.com>):
On 16 Nov 2005 13:22:33 -0800, in comp.lang.c ,
po***********@gmail.com wrote:
Sorry could you please explain more detailedly?
What's line 42?

"The Answer". To the question. Of Life. The Universe. Well, Everything,
really.

Your job: figure out "the Question".
Please read the Hitchikers Guide to the Galaxy. The meaning of "42"
will then become clear.
Actually, it won't as I recall. I thought you had to read the
sequel to find out its meaning???


No, that won't help.
It's been a number of years,
perhaps I have it wrong.


Yes, that's it. ;-)

So long, and thanks for all the..., well just thanks.

--
Mabden
Nov 23 '05 #35

P: n/a
Mabden wrote:
[...]
> Sorry could you please explain more detailedly?
> What's line 42?

"The Answer". To the question. Of Life. The Universe. Well, Everything,
really.

Your job: figure out "the Question".

[...] So long, and thanks for all the..., well just thanks.


I hereby propose a new auto-ack for "spoof@..." addresses:

So long, and thanks for all the phish.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 23 '05 #36

P: n/a
<po***********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Sorry could you please explain more detailedly?
What's line 42?
Thanks a lot!


42 is the meaning of life! Not sure what the question was though! doh!
Nov 24 '05 #37

This discussion thread is closed

Replies have been disabled for this discussion.