How to solve out of memory ??

Hemm, guys, could you help me out a bit ? Now i'm having trouble with my Turbo C... I tried compiling my program (approx. 4000 lines)... it says "out of memory in xxxx()"... I tried pushing the F1 key, the helpfile says I should simplify my source code, or use EMS to compile the things. Now how can I overcome this ?? I've tried using EMS (64K) it doesn't help a thing... Pleaseeeee !!! HELLPPP !!!
LVL 3
techpageAsked:
Who is Participating?
 
viktornetConnect With a Mentor Commented:
jjmcd, you seem to be extremely pessimistic and a stubborn person why's that?

the thing is the TC sux.... i've had the same problems, and that's not that ypu've written your code badly, but it's simply 'cuz the compiler itself sux.... I had to move to DJGPP because of that.... i had only a few lines of code in my program and TC reported that error in front of my face.... i would suggest that you try using a different compiler such as BC... that way you will have no problems at all...

..-=ViKtOr=-..
0
 
ozoCommented:
Have you tried to simplify your source code?
0
 
jjmcdCommented:
techpage - oso isn't being facetious - if you're running out of memory during compile, it's likely that your program is very badly written, and in dire need of simplification.

Generally, the compiler's memory needs run up when you have long, gangly functions with a lot of nesting.  This sort of function tends to be difficult to maintain, and difficult for the compiler to optimize.  A lot of new C programmers tend to do this because they are concerned about the cost of function calls.  Function calls are not very expensive and certainly less expensive than the alternatives.

Try breaking big functions down.  Although there are exceptions, I generally give programmers a hard time who write functions that exceed a printed page, including comments.  Unless it's basically a series of sequential steps, a function that exceeds a page will be a function you won't be able to figure out a month from now.

Break the program down into logical fragments, and code those fragments each as it's own function.  If a fragment itself is too big, break it down.  Continue breaking down your logic until your program is a series of small, concise, easy to understand functions.

As an added benefit, once you've done this you will find opportunities to optimize your code will leap out at you.
0
Turn Raw Data into a Real Career

There’s a growing demand for qualified analysts who can make sense of Big Data. With an MS in Data Analytics, you can become the data mining, management, mapping, and munging expert that today’s leading corporations desperately need.

 
obgCommented:
Try to move as much of the resident drivers and such to the upper memory area, and be sure that DOS=HIGH. This should give you at least 610 kB of working memory. If this does not work, try exiting the IDE and run the command line compiler (BCC, or TCC or something like that), followed by TLINK. That should require much less memory.
0
 
AlexVirochovskyCommented:
Test you min/max statements. If you make error in
() :not balanced,  Borlandc can stuck!
0
 
TriskelionCommented:
Split your code into separate file modules in your project.
That way, you will only need the extra memory at LINK time instead of compile time.

The functions should be grouped logically.

If you are not familiar with this concept, I can send you an example.
0
 
jjmcdCommented:
techpage - you might give us some insight into just how experienced a C programmer you are.  I realize a lot of beginning C programmers have trouble breaking a program down because they are a bit intimidated with pointers, and this can make life with C very tough.

Triskelion has a good point about separate compilation.  Generally, breaking the program down into separate functions, even if it's a separate compilation module, will do the trick.

However, if you have a syntax error that exploits a problem in the copiler, like AlexVirchovsky mentions, the separate compilation units can help you localize the problem.
0
 
jjmcdCommented:
vik - I dunno about pessimistic, but stubborn, probably so.

techpage hasn't given us any additional information, but someone using TC and writing 4000 lines of C as a single compilation unit sounds to me like someone with little experience.  I've been poking him trying to get a better read on him, but no cigar.

I don't disagree that TC sucks swamp water through a straw, and I don't disagree that DJGPP is about 100 times the compiler TC is.

But DJGPP is a bear to install.  If techpage is as inexperienced as I think he is, he'll spend the next month trying to install the bugger, and, even if he manages to get it to work,  he'll continue to write bad code.

Admittedly, it's been a long time since I used TC but back in the dark ages I saw that same error from - guess what - bad code.

So if my read on techpage is close, he is probably better off sticking with TC for a while, and learning how to get around it's limits.  At some point, he'll move to something better.  But spending a lot of time futzing with a new compiler isn't going to solve his current problem.
0
 
techpageAuthor Commented:
Wowww... guys... I liked you all a lot !!! hehehe... thanks for all of you... oh yaaa... by the way I wanna give you all a little points for solving my problem...

jjmcd, you are really a straight person, aren't ya !!! but that's no problem, yap I vaht to admit it, I have NO experience about C, and suddenly I am given this project... maybe I've created bad codes I've never concerned before, but... I also agree with Viktornet... because I've asked my senior about my problem, he also said the same thing like vik said, yahhh the TC compiler sucks !!!... Now i'm trying to move to TC++ compiler to continue my project !!!... anyway.. thanks to you all !!!

ps: let me know how to give points to everybody ???
0
 
viktornetCommented:
you already gave some to me, now you have to post a different question for each person you think deserves some points (without me, czu you gave me some already) and then when they answer simply accept their answer... the title of the question should be something like

for jjmcd, or for obg, etc.... hehe ;)

..-=ViKtOr=-..
0
 
jjmcdCommented:
tech - I've been burned a few times on EE by being surprised at how inexperienced a questioner is.  I've been in this business a long time, so sometimes things are perfectly obvious to me that might not be so obvious to someone with a different background.  So I try to look for clues.  There are some folks around here that are very, very sharp, but they tend to answer a lot more questions than they ask.

The other thing that you realize after a while is that the right answer for one person is rarely the right answer for the next, so sometimes it's helpful to get a little more context.

Sometimes, if I can't get a good read on someone it helps to be direct.  If a gentle prod doesn't produce results, something closer to an insult might.  OK, maybe I'll draw a few flames, but heck, I got a thick skin!
0
 
jjmcdCommented:
Oh and another thing, although I sometimes (usually?) disagree with Viktornet, he's pretty sharp.  Sometimes 'experts' who don't have a clue will tell you what they think you'll buy.  I've never seen Vik do that, and I've seen a *LOT* of his answers.
0
 
viktornetCommented:
jjmcd, what did you mean by sharp? In what way? Sorry, I don't get the meaning :)
0
 
jjmcdCommented:
jeez vik - looking for more compliments :-))

You know, sharp, bright, capable ...

If you don't mind my asking, I had gotten a hint once before, now that you mention it, that you might not be a native english speaker.  Is this correct?

That's the other thing that's so hard on the net - on the phone or in person, you can tell by the accent.  At work, when I get an email from someone I haven't met, I can often tell from their email address where they're from, but here all you have is -maybe- a recognizable grammatic lapse, and even then it can be pretty subtle.  I work with a lot of people from all over the world, and the cultural differences can be substantial.  It's important to know where someone is from to  understand what he means, and to say things to him in a form he won't misunderstand.

The statement "TC reported that error in front of my face" is a little suspicious - it's not incorrect english, but it's not the sort of thing a native english speaker is likely to say.  Looks more like a Dutch guy, or maybe German.  But it's real subtle.

Oh well, talk about being off topic!
0
 
viktornetCommented:
you're right... i'm not a native English speaker :) I'm originally from Bulgaria (right next to Romania, Serbia, etc...) It's a very small country, and people would have a hard time noticing it :)) you can imagine how small it is ;-)) take a look at a map or something...

>The statement "TC reported that error in front of my face" is a little suspicious -
>     it's not incorrect english, but it's not the sort of thing a native english speaker is
>     likely to say.
hehe, yep... i never look at my grammar and spelling mistakes when I'm on E-E or talking to friends (most of 'em ;-)).... If the conversation is official and it matters whether or not I use appropriate language, then I try to do my best and use it as best as i can... and E-E sure isn't one of those cases.... ;)

sometimes, i dont even think what i'm writing.. so most of the time it doesn't make any sense... hehe.... that happens when i'm tired or something... :)

i feel tired now :)

..-=ViKtOr=-..
0
 
viktornetCommented:
How come our opinions usually (always?-) differ and this is the second time you compliment me?? :)
0
 
jjmcdCommented:
Viktornet - we obviously have pretty different backgrounds.  Therefore we come to some pretty different solutions.  Your solutions are quite obviously well reasoned and are no less valid just because they are different from mine.

I've had several large projects where I've had to bring players together with very different backgrounds.  Often the 'obvious' solution to a problem is totally different depending on the person's background.  Usually the 'best' solution can borrow from all sides.  The trick is to understand what's driving the differences, and what the similarities are between the current problem and the situations these players have seen in the past.

By the way, I know where Bulgaria is, have never been there, tho.  Closest I've ever gotten is Slovakia, back when it was part of the CSFR.
0
 
obgCommented:
Well, since we are off topic already, I would like to say that even though GNU certainly have more efficient compilers, Borland has made the most easy to use C-compilers for DOS ever. I used to write in Turbo Pascal (which is still by far the best and fastest Pascal compiler for DOS) when I discovered Turbo C. I did not know C by then, but thanks to Borland I learned very quickly. And I still use BC++ 3.1 for my DOS programs. In other words, Borland dose NOT suck! They have done far better than Microsoft for example (except for marketing).

Having a slightly bad consience, I fell the urge to get on topic again, so why didn't anyone comment on my comment to use the command line compiler? - I think that is a very good idea, and it has helped me many times... Of course, maybe he already does, but I don't think so. It should be able to take 4000 ines of code.
0
All Courses

From novice to tech pro — start learning today.