Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Memory leaks ?
Memory leaks ? [message #51767] Mon, 20 May 2019 13:49 Go to next message
Xemuth is currently offline  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 : https://img.raymond.cc/blog/wp-content/uploads/2009/08/stopped_working_no_WER.png
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 ? Very Happy

Thanks in advance

have a good day !
Re: Memory leaks ? [message #51768 is a reply to message #51767] Mon, 20 May 2019 14:14 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
OK, I have fixed my probleme by using :

CopyFile(WhereToGet.ToStd().c_str(),exeToLaunch.ToStd().c_str(),FALSE)

instead of
Upp::FileCopy(WhereToGet.ToStd().c_str(),exeToLaunch.ToStd().c_str())


Does it mean Upp::FileCopy is not working as intended or don't clean is memory allocation properly ?

Thanks for you responses.

Best Regard.
Previous Topic: Compiling app using theIde command line ? (linux)
Next Topic: Value strange behaviour result in ValueTypeError
Goto Forum:
  


Current Time: Fri Apr 19 05:42:35 CEST 2024

Total time taken to generate the page: 0.02258 seconds