Link to home
Create AccountLog in
Avatar of xNejX
xNejXFlag for Canada

asked on

How do I clear an EXE's IPC Shared Memory?

Hi,

I have an EXE that does some IPC to another EXE via the shared memory. It is working great, it is fast and low usage on the CPU. But when i look at the memory usage of the EXE that is sending the call through shared memory (Windows Task Manager), I can see the memory usage getting bigger and bigger every second (It sends a message to another EXE twice every second -- 500 mil.).

So I am probably doing something wrong, by not clearing the memory or variables or something right? I don't know if i should clear anything when I am done with the sending / writing to memory or let the other - receiving EXE clear it when it successfully receives it?

This is my "Sending Code";

void IPCsend (std::string strDataToSend){

        HWND hWnd = ::FindWindow(NULL, "IPCreciever");

	if (hWnd)
	{
		COPYDATASTRUCT cpd;
		cpd.dwData = 0;
		cpd.cbData = strDataToSend.length();
		cpd.lpData = (void*)strDataToSend.c_str();

		::SendMessage(hWnd, WM_COPYDATA, (WPARAM)::GetDesktopWindow(), (LPARAM)&cpd);		
	}
}

Open in new window


Thank you for your help,
Avatar of jkr
jkr
Flag of Germany image

There's nothing wrong with the above, see also http://www.codeproject.com/KB/threads/ipc_wmcopy.aspx ("Inter-Process Communication using WM_COPYDATA") - your memory leak is probably located elsewhere...
Avatar of xNejX

ASKER

Thank you jkr, but if don't run that part the memory does not increase like that... Is there no clearing or deleting variables that could help?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account