Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Don't know what happens, my application just hang

Posted on 2003-03-07
12
Medium Priority
?
195 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:http29
  • 4
  • 3
  • 3
  • +2
12 Comments
 
LVL 6

Expert Comment

by:gj62
ID: 8090391
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
 
LVL 8

Expert Comment

by:Exceter
ID: 8090411
>> 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
 
LVL 10

Expert Comment

by:substand
ID: 8090827
are you forgetting to get out of a loop?  are you accessing null pointers?

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:http29
ID: 8091186
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
 
LVL 6

Expert Comment

by:gj62
ID: 8091255
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
 
LVL 5

Expert Comment

by:Kocil
ID: 8093066
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
 
LVL 5

Expert Comment

by:Kocil
ID: 8093072
If the model is already large or huge,
don't use Borland C++ anymore and switch to DJGPP.
0
 

Author Comment

by:http29
ID: 8098272
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
 
LVL 6

Expert Comment

by:gj62
ID: 8098532
For DJGPP, go here:

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

0
 
LVL 5

Expert Comment

by:Kocil
ID: 8099402
DJGPP is free,
but i'm not sure about the license (GPL or else).
0
 
LVL 5

Accepted Solution

by:
Kocil earned 240 total points
ID: 8099857
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
 

Author Comment

by:http29
ID: 8129876
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

581 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