From: Jochen Kalmbach [MVP] on
Hi Luc!

> I was able to reproduce this problem.
> To my surprise, CreateProcess keeps eating memory!!!

On XP-SP2, I was not able to repro the problem...

Here is my code:

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

int _tmain()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ULONG ulCount = 0;

LPTSTR szWritableCmd = new TCHAR[1024];
while(true) {
ZeroMemory(&si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi) );

LPCTSTR szCmd = _T("%SystemRoot%\\system32\\cmd.exe /c");
ExpandEnvironmentStrings(szCmd, szWritableCmd, 1024);
if(CreateProcess(NULL, szWritableCmd, NULL, NULL, FALSE, 0,
NULL, NULL, &si, &pi) != FALSE)
{
ulCount++;
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD ExitCode;
GetExitCodeProcess(pi.hProcess, &ExitCode);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
if ((ulCount % 10) == 0)
_tprintf(_T("%d\n"), ulCount);
}
else
{
_tprintf(_T("Error creating process..."));
}
}
delete [] szWritableCmd;
}


Greetings
Jochen
From: Luc Kumps on
Jochen Kalmbach [MVP] wrote:
> Hi Luc!
>
>> I was able to reproduce this problem.
>> To my surprise, CreateProcess keeps eating memory!!!
>
> On XP-SP2, I was not able to repro the problem...

I can't reproduce it on XP-SP2 either.
By the way, here's the code needed to show the memory usage at runtime:

#include <psapi.h>
using namespace std;

void showMemInfo() {
PROCESS_MEMORY_COUNTERS pmc;
if ( GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)) ) {
cout << pmc.PagefileUsage << ".";
}
}

On my Win2000-SP4 this eats memory in 'steps' of 4096 or 8192 bytes...
On a Windows NT 4.0 system (tested in VMWARE), no leak either.

Luc


From: Hector Santos on
Touch?!! <g>


"David J. Craig" <Dave(a)yoshimuni.com> wrote in message
news:#9AH8#hUGHA.1304(a)tk2msftngp13.phx.gbl...
> No. Please don't bottom post.
>
> "Arnaud Debaene" <adebaene(a)club-internet.fr> wrote in message
> news:%23vw0rYeUGHA.1688(a)TK2MSFTNGP11.phx.gbl...
> > lugeon wrote:
> >> "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?
> >>
> >> With Purify
> >
> > What does is says exactly? Where does it locate the leak?
> >
> > PS : Please don't top-post
> >
> > Arnaud
> > MVP - VC
> >
> >
>
>

First  |  Prev  | 
Pages: 1 2 3 4
Prev: LowLevelHooksTimeout?
Next: Hook Windows Events