|
Anonymous wrote:
Has anyone come across this before.
No, and I can't imagine anyone would under most circumstances.
You are encroaching on the 2GB limit. If you were using an OS that supported it, the /3GB switch would possibly get you access to a larger stack.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
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 ).
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;
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;
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;
|
|
|
|
|
Hi all,
I'm writing a WinNT service. My service prog will have to receive a user defined(or registered) message from another service based platform.but the based platform service is designed to send message to application(i think it has bind the application's desktop with SetThreadDesktop function). my service can not receive any message from it.
can anybody help me?what should i do to receive the message?
|
|
|
|
|
did you set SERVICE_INTERACTIVE_PROCESS
for interacibg with desktop ...
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
yes,i had set SERVICE_INTERACTIVE_PROCESS,but can not receive.
|
|
|
|
|
Hello!
I've read that when working with the CToolTipCtrl, you have to either relay the mouse messages to it, or do some kind of subclassing. I've chosen to relay the messages, and I thought that the logical thing was to do this through OnMouseMove, and I did something like:
void X::OnMouseMove(...)
{
MyToolTip.RelayEvent(const_cast<msg*>(GetCurrentMessage()));
}
I used the const_cast because otherwise the compiler complained about GetCurrentMessage being const!
Well... Didn't work! Now I have found out that I must relay the messages in PreTranslateMessage, and that works nicely... But why can't i relay in OnMouseMove ?
Thanks in advance
|
|
|
|
|
Damn html-tags!
void X::onmousemove(...)
{
MyToolTip.RelayEvent(const_cast<MSG*>(GetCurrentMessage()));
}
|
|
|
|
|
Do it in
X::PreTranslateMessage()
Hope it will work.
modified 7-Jan-15 8:19am.
|
|
|
|
|
Dear All,
I am working on my project (in MFC) which require me to run certain function every minute...I would like to know how I can do so except using a loop to check if the time is reached. I would prefer a "signal and slot" like method as there are some other functions need to run so I can use loop method to do so ~_~
Thanks~
|
|
|
|
|
|
|
thats okey toxcct
they shld check codeproject b4 msdn.
tats our aim...
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Yes. this is should be the first choice, even before MSDN. Rather microsoft should trigger it with F1.
|
|
|
|
|
Thats sounds nice, to have F1 shortcut to codeproject.;)
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
download the CodeProject ToolBar so...
TOXCCT >>> GEII power
|
|
|
|
|
USE THIS
#define ID_timer 1000
use add window handler to deliver window message WM_TIMER
OnTimer
SetTimer(ID_timer,1000*60,NULL);
to end timer
KillTimer(ID_timer);
Alok Gupta
visit me at http://alok.stormpages.com
|
|
|
|
|
|
What are you saying? When a timer is no longer needed, of course KillTimer() should be called. Even though a few WM_TIMER messages may still be in the queue, the message-handling function can react accordingly.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
yes, but Alok seems to calls KillTimer() at the end of OnTimer()
Maybe i'm wrong, but that's not clear...
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
Maybe i'm wrong, but that's not clear...
While he could have highlighted the code and text better so that they did not appear to be one, I think he was just showing how to start a timer, and then how to stop a timer.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
you are right buddy
i am showing how to start a one minute timer and stop it to help him/her to understand problem
Alok Gupta
visit me at http://alok.stormpages.com
|
|
|
|
|
|
hey man, go sleeping, of course we're speaking about C++ !!!
TOXCCT >>> GEII power
|
|
|
|
|
standard INI file should be connected with regedit,
for example the two lines below:SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
i know when "setRegistryKey(_T("Local AppWizard_Generated Applications")"
we can find it in regedit,but i don't know the use of the "LoadStdProfileSettings(); "
|
|
|
|
|
From the documentation:
"Call this member function from within the InitInstance member function to enable and load the list of most recently used (MRU) files and last preview state. If nMaxMRU is 0, no MRU list will be maintained."
The code for CWinApp::LoadStdProfileSettings can be found in APPCORE.CPP in the MFC source; this uses an internal MFC class CRecentFileList to manage the list of recently-used files maintained by the application. The implementation of CRecentFileList can be found in FILELIST.CPP.
You can normally find the MFC source for VS6 in C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC. If it's not there, you can install it from the CD.
The framework stores the MRU information under a key called 'Recent File List' under your application's registry key.
The 'last preview state' refers to print preview; this code saves and restores the number of pages shown (one or two) when showing a print preview.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|