steg90
10th May 2007, 13:52
Hi,
For some reason, when checking the physical memory in task manager when the thread below is running, the memory keeps going down, I cannot understand why?
void CanRead::run()
{
m_nCount = 0;
m_bCancelled = false;
unsigned long nMsgAmount = 2;
CANDATA can[MAX];
while( !m_bCancelled )
{
unsigned long numMsgs = 0;
PASSTHRU_MSG *pRxMsg = NULL;
pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
nMsgAmount = numMsgs; // store amount of messages we got
int index = 0;
// Read can data, store in buffer ( read say N amount and then emit? )
while ( numMsgs && !m_bCancelled )
{
QString szTemp = "";
can[index].strData = "";
unsigned int iCanId = 0;
for ( int iLoop = 0; iLoop < 4; iLoop++)
{
iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
}
if( pRxMsg->RxStatus & 0x100 )
can[index].strId.sprintf( "%X X", iCanId);
else
can[index].strId.sprintf( "%03X", iCanId);
for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
{
szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
can[index].strData += szTemp;
}
can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
numMsgs--;
m_nCount++;
} // end while ( ulNoMsgs )
msleep(1);
} // end while ( true )
}
I thought it might have been the call to GetMessageDetail, but commenting this out and the memory still leaks?
Anyone any ideas?
Kind regards,
Steve
For some reason, when checking the physical memory in task manager when the thread below is running, the memory keeps going down, I cannot understand why?
void CanRead::run()
{
m_nCount = 0;
m_bCancelled = false;
unsigned long nMsgAmount = 2;
CANDATA can[MAX];
while( !m_bCancelled )
{
unsigned long numMsgs = 0;
PASSTHRU_MSG *pRxMsg = NULL;
pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
nMsgAmount = numMsgs; // store amount of messages we got
int index = 0;
// Read can data, store in buffer ( read say N amount and then emit? )
while ( numMsgs && !m_bCancelled )
{
QString szTemp = "";
can[index].strData = "";
unsigned int iCanId = 0;
for ( int iLoop = 0; iLoop < 4; iLoop++)
{
iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
}
if( pRxMsg->RxStatus & 0x100 )
can[index].strId.sprintf( "%X X", iCanId);
else
can[index].strId.sprintf( "%03X", iCanId);
for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
{
szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
can[index].strData += szTemp;
}
can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
numMsgs--;
m_nCount++;
} // end while ( ulNoMsgs )
msleep(1);
} // end while ( true )
}
I thought it might have been the call to GetMessageDetail, but commenting this out and the memory still leaks?
Anyone any ideas?
Kind regards,
Steve