Hi,
I am creating a C++ dll which is used to process data passed to it
through one of its exported functions. It should be able to process
160 simultaneous requests. For this reason, I have initiated 10 child
threads from the main thread and maintaining a queue of nodes
containing the data to be processed.
The queue node strucute is as follows:
struct SQueueNode
{
SData *m_pData;
bool m_bInProcess;
char* m_strReturnInfo;
SQueueNode *m_pNextNode;
};
As a node is created and added to queue, one of the free child threads
processes the data. It allocates memory for the char* m_strReturnInfo
of the queue node being processed and puts some info into that and
sets the boolean field (m_bInProcess) of the queue node structure to
false and then waits for more requests.
But when the processed node is deleted from the main thread, the
program crashes at the statement where the dynamic memory allocated
for m_strReturnInfo is deleted.
Can I not delete the dynamic memory in a parent thread that is
allocated from a child thread ?
Thx. in advance.
Manisha