Click here to Skip to main content
15,921,660 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: saving complete webpage to HD (with images) Pin
2249179-Apr-04 3:41
2249179-Apr-04 3:41 
GeneralRe: saving complete webpage to HD (with images) Pin
midupk11-Apr-04 23:07
midupk11-Apr-04 23:07 
GeneralProject settings for initial stack Pin
Anonymous9-Apr-04 1:22
Anonymous9-Apr-04 1:22 
GeneralRe: Project settings for initial stack Pin
David Crow9-Apr-04 3:50
David Crow9-Apr-04 3:50 
GeneralCAsyncSocket Client/server Pin
VBZ9-Apr-04 1:21
VBZ9-Apr-04 1:21 
General2G limit when creating threads Pin
Anonymous9-Apr-04 1:17
Anonymous9-Apr-04 1:17 
GeneralRe: 2G limit when creating threads Pin
David Crow9-Apr-04 3:53
David Crow9-Apr-04 3:53 
GeneralRe: 2G limit when creating threads Pin
Gary R. Wheeler9-Apr-04 4:50
Gary R. Wheeler9-Apr-04 4:50 
This is a basic Windows constraint, in that they 'reserve' virtual addresses for the requested stack space for each thread, and they constrain the total amount of reserved space so that it fits within the 2 Gb process memory limit.

Taking a guess, you are implementing a multithreaded algorithm that is heavily recursive, with lots of local data at each recursive call (therefore the need for the huge stack). This is something I've seen in the artificial intelligence courses I took (a long time ago, I'll admit Blush | :O ).

The constraint here is that specifying a stack size S constrains the number of threads T, such that (S * T) < 2 Gb. The key to getting around this constaint is to move the data from the stack to the heap.

Here's an example. Suppose our original recursive function looks like this:
struct S {
    char BigBlobOfData[100000];
};
void F()
{
    S s;
    // do stuff with 's'
    //...
    // now call F recursively
    F();
}
Every recursive call deeper you go uses an 'S'-sized chunk of stack. Therefore, if you need to recurse N levels, you need a stack depth of at least (N * S), and this gets applied to your constraint for the number of threads. If you used the heap instead:
void F()
{
    S *s = new S;
    // do stuff with 's'
    //...
    // now call F recursively
    F();
}
the stack required for each recursive call is only the size of the pointer. Therefore, for the same depth of recursion, you require far less stack space. This lets you increase the number of threads.

The big caveat to all this is: you've only got so much memory available. Whether it's allocated on the stack or the heap, this approach doesn't address the fact that your algorithm is memory-intensive. It's just given you a little more flexibility.


Software Zen: delete this;
GeneralService can't receive message from another service Pin
tank10259-Apr-04 1:16
tank10259-Apr-04 1:16 
GeneralRe: Service can't receive message from another service Pin
2249179-Apr-04 3:55
2249179-Apr-04 3:55 
GeneralRe: Service can't receive message from another service Pin
tank10259-Apr-04 18:27
tank10259-Apr-04 18:27 
GeneralCToolTipCtrl::RelayEvent Pin
pie9-Apr-04 1:06
pie9-Apr-04 1:06 
GeneralJust a correction Pin
pie9-Apr-04 1:08
pie9-Apr-04 1:08 
GeneralRe: CToolTipCtrl::RelayEvent Pin
Sharif Ahmad7-Jan-15 2:18
professionalSharif Ahmad7-Jan-15 2:18 
QuestionHow to run a function every minute? Pin
StarMeteor8-Apr-04 22:53
StarMeteor8-Apr-04 22:53 
AnswerRe: How to run a function every minute? Pin
GflPower8-Apr-04 22:55
GflPower8-Apr-04 22:55 
AnswerRe: How to run a function every minute? Pin
toxcct8-Apr-04 23:03
toxcct8-Apr-04 23:03 
GeneralRe: How to run a function every minute? Pin
2249178-Apr-04 23:30
2249178-Apr-04 23:30 
GeneralRe: How to run a function every minute? Pin
SiddharthAtw9-Apr-04 1:09
SiddharthAtw9-Apr-04 1:09 
GeneralRe: How to run a function every minute? Pin
2249179-Apr-04 3:33
2249179-Apr-04 3:33 
GeneralRe: How to run a function every minute? Pin
toxcct9-Apr-04 4:06
toxcct9-Apr-04 4:06 
AnswerRe: How to run a function every minute? Pin
ThatsAlok9-Apr-04 3:06
ThatsAlok9-Apr-04 3:06 
GeneralRe: How to run a function every minute? Pin
toxcct9-Apr-04 3:39
toxcct9-Apr-04 3:39 
GeneralRe: How to run a function every minute? Pin
David Crow9-Apr-04 3:59
David Crow9-Apr-04 3:59 
GeneralRe: How to run a function every minute? Pin
toxcct9-Apr-04 4:05
toxcct9-Apr-04 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.