Hi,
In my application I'm using tsq for collecting incoming instructions from other device (user), proccessing them, and then replying according to each instruction. Program has one thread for receiving, and another thread for processing instruction. Application doesn't know when and how many instructions is coming, so every instruction is read and proccessed immediately (one element written in tsq, and one element read from tsq). Type of data written in tsq is structure consists of few chars, ints etc. of size approx. 50 Kb.
My problem is that every time writer thread puts instruction in tsq, memory usage increases for size of that element, but when other thread reads the data, memory usage remains the same, causing memory leakage. Since my application must run continously for a long time, it is a problem because after some time (depends on number of incomming instructions) it crashes.
This is receiving of data and puting it to tsq:
static void CVICALLBACK Receiveinstruction (void *data)
{
typedef struct KomData
{
char comm_id[100];
unsigned int status;
int type;
char user[256];
unsigned int handle;
unsigned int priority;
char command[50000];
unsigned int threadId;
unsigned int threadId_2;
char *result_ptr;
} KomData;
KomData komData;
KomData *komDataPtr = &komData;
/*
.... part which receive data from user....
*/
CmtWriteTSQData (tsqHandle, komDataPtr, 1, TSQ_INFINITE_TIMEOUT, NULL);
/*
.... other ....
*/
}
This is reading from tsq:
void CVICALLBACK ReadTSQ (int queueHandle, unsigned int event, int value, void *data)
{
KomData komData;
KomData *komDataPtr = &komData;
/*
.......
*/
numItemsRead = CmtReadTSQData (queueHandle, &komData, numItemsRead, TSQ_INFINITE_TIMEOUT, 0);
komDataPtr = &komData;
/*
.......
*/
}
Thanks for any suggestions.
Pero