Don't know what happens, my application just hang

Hi Guru:

I am so frustrated with my application. I run it and it hangs, not giving me any message. Finally I found that my application might reach maximum size. I don't know, just guess. I use Borland C++. I have to change the code to reduce the size, then I can run it. But the problem is that I still need add more code. I don't understand, my code could be any large and should not be limited to some size. Please let me know what is real problem. Every time I add more codes, I got problem. I reduced and then can run it. Thanks.
http29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gj62Commented:
How much are you putting on the stack, vs on the heap?

Sounds like you are reaching a stack size issue.

Are you creating any large arrays, or medium size arrays with large structures?  If so, consider putting them on the heap with malloc().

Of course, this is all a SWAG since I've got no idea what your code looks like...

0
ExceterCommented:
>> I have to change the code to reduce the size, then I can run it. But the problem is that I still need add more code.

Are you sure that the code you are removing isn't causing the program to freeze?

Exceter
0
substandCommented:
are you forgetting to get out of a loop?  are you accessing null pointers?

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

http29Author Commented:
I am sure that the code I removed doesn't cause the programm to freeze because I just removed debug statements like cout << "..." << endl; Also I am not getting into the loop, should be not accessing null pointer, otherwise, I should get error message at least. Probably I am reaching a stack size. I do have large size array. What u mean by SWAG or by "putting them on the heap with malloc()". U mean using dynamic allocated memory instead of large array? Can I increase the stack size? How can I know how much I put on the stack, how much on the heap. Thanks.
0
gj62Commented:
SWAG = Scientific Wild A** Guess, or something to that approximation <grin>

To dynamically allocate memory (on heap instead of stack), instead of saying

type ReallyBigArray[arraysize]; or something like it, try

type *ReallyBigArray;

ReallyBigArray = (type *)malloc(sizeof(type) * arraysize);

Type can be anything - char, int, struct, etc.

I don't use Borland, but I think you can find (and even set) the stack size using the _stklen global variable.  I suggest, however, that a much better method would be to dynamically allocate the array (and any other large blocks of memory) on the heap.  As far as heap space - how much memory do you have... <grin>  

If this doesn't do it, what OS version and version of the compiler are you running under?  I probably can't help too much more, since manipulating stack size is done within each compiler, and as I said, I don't have Borland...
0
KocilCommented:
Check your Options-Compiler-Code Generation.
If the model there is tiny, small or compact, you have the chance to fix it by using large or huge model.

0
KocilCommented:
If the model is already large or huge,
don't use Borland C++ anymore and switch to DJGPP.
0
http29Author Commented:
Hi Kocil:

My model is huge model like you said. How easy to switch to DJGPP. I never used this one before and my project doesn't allow me more time to learn. We alreay released two versions. We got to keep going. So your help would be very much appreciated. Is DJGPP free download or need to buy? How much it is or the website? Thank you so much.
0
gj62Commented:
For DJGPP, go here:

http://www.delorie.com/djgpp/

0
KocilCommented:
DJGPP is free,
but i'm not sure about the license (GPL or else).
0
KocilCommented:
About three years ago I was switching from Borland C++ 3.1 to DJGPP:
1. The IDE is similar. DJGPP use RHIDE which is build using Turbo Vision.
2. All standard C++ libraries worked fine.
3. BGI did not work, I have to use another VESA graphic libary (available from DJGPP site).
4. Borland data structure did not work, but I switched to STL.

But that 3 years ago. I just visited the DJGPP site again, and there ara a lot of new libraries, including networking. /* The one that I wanted so much, too late now :) */



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
http29Author Commented:
Thank both Kocil and qj62. I understand that only one comment of your comments will be accepted as my answers. I feel very tough but would give to Kocil this time. But I really appreciate qj62.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.