Hello,
i got problem when i run multiple background application with my main application how i overcome that problem. it prompt like this "Cannot start Cat. A critical component is either missing or failing due to low memory." this prompt occur randomly no specific timings is there any mistake in the code or why this error occur at random interval. sometime not occur but some time its frequency increases to much.
BOOL CatApp::IsProcessRunning(
char* pname){
char* szExeFile = new char[MAX_PATH];PROCESSENTRY32 proc;
proc.dwSize =
sizeof(PROCESSENTRY32);HANDLE lTlhlpHndl;
lTlhlpHndl = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
if(INVALID_HANDLE_VALUE != lTlhlpHndl){
PROCESSENTRY32 lEntry;
BOOL lRetVal;
memset(&lEntry,0,
sizeof(PROCESSENTRY32));lEntry.dwSize =
sizeof(PROCESSENTRY32);lRetVal = Process32First(lTlhlpHndl,&lEntry);
while(lRetVal){
WideCharToMultiByte(CP_ACP, 0, (
wchar_t*) lEntry.szExeFile, -1, szExeFile,20, NULL, NULL); if (strcmp(pname,szExeFile) == 0){
CloseToolhelp32Snapshot(lTlhlpHndl);
delete[] szExeFile; return TRUE;}
lRetVal = Process32Next(lTlhlpHndl,&lEntry);
}
CloseToolhelp32Snapshot(lTlhlpHndl);
}
delete[] szExeFile;
return FALSE;
}
CatApp theApp;
BOOL CatApp::InitInstance()
{
SHInitExtraControls();
BOOL b;
int n=2,m=2;
Gstr = new char[125];
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_FLAG_NO_UI;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = L"\\Program Files\\My\\abc.exe";
ShExecInfo.lpParameters = L"";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWNA;
ShExecInfo.hInstApp = NULL;
SHELLEXECUTEINFO ShExecInfo1 = {0};
ShExecInfo1.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo1.fMask = SEE_MASK_FLAG_NO_UI;
ShExecInfo1.hwnd = NULL;
ShExecInfo1.lpVerb = NULL;
ShExecInfo1.lpFile = L"\\Program Files\\My\\xyz.exe";
ShExecInfo1.lpParameters = L"";
ShExecInfo1.lpDirectory = NULL;
ShExecInfo1.nShow = SW_SHOWNA;
ShExecInfo1.hInstApp = NULL;
BOOL b1;
DWORD error;
MEMORYSTATUS memstate;
int count=0;
while (count++ < 240)
{
if (n == 2)
{
n = 0;
b = IsProcessRunning("abc.exe");
if (!b)
{
GlobalMemoryStatus(&memstate);
FILE* file = fopen("\\Program Files\\My\\abc.exe", "ab");
if(file == NULL)
{
continue;
}
else
{
fclose(file);
}
b1 = ShellExecuteEx(&ShExecInfo);
if (b1)CloseHandle(ShExecInfo.hProcess);
else{
error = GetLastError();
}
}
}
if (m == 4)
{
m = 0;
CheckSettings();
if (Enable)
{
b = IsProcessRunning("xyz.exe");
if (!b)
{
GlobalMemoryStatus(&memstate);
FILE* file = fopen("\\Program Files\\My\\xyz.exe", "ab");
if(file == NULL)
{
continue;
}
else
{
fclose(file);
}
b1 = ShellExecuteEx(&ShExecInfo1);
if (b1)elseCloseHandle(ShExecInfo1.hProcess);
{
error = GetLastError();
}
}
}
}
n++;
m++;
Sleep(5000);
}
if (Gstr)
delete[] Gstr;
return TRUE;
}
How i manage this problem i have put my all efforts init but have find out the real track to remove this error.
Thanks
Salman

Low memory error. (critical component)
Joseph Moraise
Hello,
all the heap and reserve sizes are zero and process limit is not excedding from 32. this is sure. check the code. any problem or correction is appreciated
sub system = notset
default and notset and 0 are set in the parameter no new thing is there.
Thanks
Salman
John Oliver &#40;UK&#41;MSP, VSIP
Please make sure to use TH32CS_SNAPNOHEAPS flag in your call to CreateToolhelp32Snapshot().
Kaiser28
Looks like some too much memory is being reserved by your processes. You may want to consider changing the project settings to so that the stack commit and reserve sizes are smaller. ( Project Properties > Linker > System Tab).
Also see that you are not exceeding the 32 process limit on CE device.
Hope this helps.