Prev: LowLevelHooksTimeout?
Next: Hook Windows Events
From: lugeon on 27 Mar 2006 07:31 I get a 388bytes memory leak each time I call the CreateProcess() function. Here is my following code: void main(int argc, char* argv[]) { STARTUPINFO si; // = { sizeof(si) }; PROCESS_INFORMATION pi; while (true) { ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if(CreateProcess(NULL,"C:\\temp\\TestFile.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { WaitForSingleObject(pi.hProcess, INFINITE); DWORD ExitCode; GetExitCodeProcess(pi.hProcess, &ExitCode); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } else { cout << "Error CreateProcess()..." << endl; } } } I use Visual .Net and Windows 2000 Professional. With XP or XP Embedded, the problem is still here. Can anybody tell me what is the trouble with my code?
From: adebaene on 27 Mar 2006 10:05 lugeon wrote: > I get a 388bytes memory leak each time I call the CreateProcess() function. > Here is my following code: <snip> The code looks just fine. How do you measure those 388 bytes? Arnaud MVP - VC
From: lugeon on 27 Mar 2006 10:52 With Purify "adebaene(a)club-internet.fr" a écrit : > > lugeon wrote: > > I get a 388bytes memory leak each time I call the CreateProcess() function. > > Here is my following code: > <snip> > > The code looks just fine. How do you measure those 388 bytes? > > Arnaud > MVP - VC > >
From: Alexander Grigoriev on 27 Mar 2006 10:58 By the way, you're NOT supposed to pass a constant string to CreateProcess. "lugeon" <lugeon(a)discussions.microsoft.com> wrote in message news:433B7B08-FF3F-4CDD-B97D-28A2C5888013(a)microsoft.com... >I get a 388bytes memory leak each time I call the CreateProcess() function. > Here is my following code: > > void main(int argc, char* argv[]) > { > STARTUPINFO si; // = { sizeof(si) }; > PROCESS_INFORMATION pi; > > while (true) { > ZeroMemory( &si, sizeof(si) ); > si.cb = sizeof(si); > ZeroMemory( &pi, sizeof(pi) ); > > if(CreateProcess(NULL,"C:\\temp\\TestFile.exe", NULL, NULL, FALSE, 0, > NULL, NULL, &si, &pi)) > { > WaitForSingleObject(pi.hProcess, INFINITE); > > DWORD ExitCode; > GetExitCodeProcess(pi.hProcess, &ExitCode); > > CloseHandle(pi.hProcess); > CloseHandle(pi.hThread); > } > else > { > cout << "Error CreateProcess()..." << endl; > } > } > } > > I use Visual .Net and Windows 2000 Professional. With XP or XP Embedded, > the > problem is still here. > > Can anybody tell me what is the trouble with my code? >
From: lugeon on 27 Mar 2006 11:22
You are right... But I write here the simplest code I could wrote. My leak is still present if I replace my constant string by a LPTSTR. Am I the only one to get a leak with this code, or has anybody the same trouble? My question is: It is the code itself, the configuration of the compiler, or something else I don't understand. I have this leak with different computer, and I also compile with different computer. If you run this simple code, you will see the memory for this application that will increase with the task manager. No need to use purify or anything else to test. "Alexander Grigoriev" a écrit : > By the way, you're NOT supposed to pass a constant string to CreateProcess. > > "lugeon" <lugeon(a)discussions.microsoft.com> wrote in message > news:433B7B08-FF3F-4CDD-B97D-28A2C5888013(a)microsoft.com... > >I get a 388bytes memory leak each time I call the CreateProcess() function. > > Here is my following code: > > > > void main(int argc, char* argv[]) > > { > > STARTUPINFO si; // = { sizeof(si) }; > > PROCESS_INFORMATION pi; > > > > while (true) { > > ZeroMemory( &si, sizeof(si) ); > > si.cb = sizeof(si); > > ZeroMemory( &pi, sizeof(pi) ); > > > > if(CreateProcess(NULL,"C:\\temp\\TestFile.exe", NULL, NULL, FALSE, 0, > > NULL, NULL, &si, &pi)) > > { > > WaitForSingleObject(pi.hProcess, INFINITE); > > > > DWORD ExitCode; > > GetExitCodeProcess(pi.hProcess, &ExitCode); > > > > CloseHandle(pi.hProcess); > > CloseHandle(pi.hThread); > > } > > else > > { > > cout << "Error CreateProcess()..." << endl; > > } > > } > > } > > > > I use Visual .Net and Windows 2000 Professional. With XP or XP Embedded, > > the > > problem is still here. > > > > Can anybody tell me what is the trouble with my code? > > > > > |