1

I have a worker thread which collects data from an external device. The worker thread keeps the main thread with the UI informed about its state. For this I'm using variations of:

SendMessage( hwndParentThread, WM_NOTIFY, 0, TEXT("Connection successful.")).

Now, the debugger complains about a memory leak. As I'm not really sure about what happens with the memory allocated for the strings I'm wondering whether the leak stems from the strings I pass between the threads (e.g. TEXT("Connection successful.")).

If anyone could point me into the right direction I would really appreciate it.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

1 Answers1

1

In C++ Literal text constants have static location (e.g. memory for "Connection successful." string is not allocated during function call). See this answer for details https://stackoverflow.com/a/349031/1025209.

I can't see any problems with your line of code. Is the memory leak exactly in this line?

Community
  • 1
  • 1
nevermind
  • 2,300
  • 1
  • 20
  • 36