Reputation: 66945
I know it looks not necessary but I hope that it would help me find memory leak. So having a function inside a class that returns int, how can I call it from another function of that class (call it so that function that returns int would run in another thread)?
Upvotes: 0
Views: 159
Reputation: 101456
The operating system will not reclaim memory leaks in worker threads. That's not how it works.
Fix your bugs. The world doesn't need any more crappy software.
Upvotes: 1
Reputation: 37930
Thread programming 101:
Notice that foo() cannot return its value to the original thread; it must write the value to some shared memory (ie, global variable). Also note that this will not solve your memory leak problem, or even make it obvious where your memory leak is coming from.
Look for memory leaks with Valgrind. And read a book or tutorial about multithreading.
Upvotes: 2
Reputation: 15872
You are trying to find a memory leak in a function by having it called from another thread? That is like trying to find a needle in a haystack by adding more hay to the stack.
Upvotes: 2