?
Solved

How to solve out of memory ??

Posted on 1999-06-26
18
Medium Priority
?
299 Views
Last Modified: 2010-04-15
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 !!!
0
Comment
Question by:techpage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
  • +4
18 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1262999
Have you tried to simplify your source code?
0
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263000
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
 
LVL 2

Expert Comment

by:obg
ID: 1263001
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1263002
Test you min/max statements. If you make error in
() :not balanced,  Borlandc can stuck!
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 1263003
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
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263004
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
 
LVL 10

Accepted Solution

by:
viktornet earned 80 total points
ID: 1263005
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
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263006
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
 
LVL 3

Author Comment

by:techpage
ID: 1263007
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1263008
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
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263009
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
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263010
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1263011
jjmcd, what did you mean by sharp? In what way? Sorry, I don't get the meaning :)
0
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263012
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1263013
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1263014
How come our opinions usually (always?-) differ and this is the second time you compliment me?? :)
0
 
LVL 3

Expert Comment

by:jjmcd
ID: 1263015
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
 
LVL 2

Expert Comment

by:obg
ID: 1263016
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question