Home » Community » Newbie corner » Memory leaks ?
Memory leaks ? [message #51767] |
Mon, 20 May 2019 13:49 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello Community,
Today I write a simple piece of code :
int main(int argc, const char *argv[])
{
if(argc >0 && Upp::String(argv[0]).Find("@" ) != -1 ){
Upp::String arg = Upp::String(argv[0]) ;
arg.Replace("@"," ");
Upp::String exeToLaunch = arg.Left(arg.Find(";"));
Upp::String WhereToGet =arg.Right(arg.GetCount()-(arg.Find(";")+1)); //Here I got my both path
if(Upp::FileCopy(WhereToGet.ToStd().c_str(),exeToLaunch.ToStd().c_str())){
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process. */
std::cout << "process creation ! \n";
if( CreateProcess(exeToLaunch.ToStd().c_str(), // No module name (use command line)
NULL, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
WaitForSingleObject(pi.hProcess,INFINITE);
cout << "succes !" <<"\n";
}
else
{
cout <<"error"<<"\n";
}
}
}
}
this code work like a charm but at the end of it I have this thing :
Seems to be a memory leak but I really don't see from what it come.
After few tests I figured out that it could come from this : Upp::FileCopy(WhereToGet.ToStd().c_str(),exeToLaunch.ToStd().c_str())
Someone with more experience than me could help ?
Thanks in advance
have a good day !
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 16:27:02 CEST 2024
Total time taken to generate the page: 0.02727 seconds
|