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?

Qt Code:
  1. void CanRead::run()
  2. {
  3. m_nCount = 0;
  4.  
  5. m_bCancelled = false;
  6. unsigned long nMsgAmount = 2;
  7.  
  8. CANDATA can[MAX];
  9.  
  10.  
  11. while( !m_bCancelled )
  12. {
  13.  
  14. unsigned long numMsgs = 0;
  15. PASSTHRU_MSG *pRxMsg = NULL;
  16. pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
  17. nMsgAmount = numMsgs; // store amount of messages we got
  18. int index = 0;
  19. // Read can data, store in buffer ( read say N amount and then emit? )
  20. while ( numMsgs && !m_bCancelled )
  21. {
  22. QString szTemp = "";
  23. can[index].strData = "";
  24. unsigned int iCanId = 0;
  25. for ( int iLoop = 0; iLoop < 4; iLoop++)
  26. {
  27. iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
  28. }
  29. if( pRxMsg->RxStatus & 0x100 )
  30. can[index].strId.sprintf( "%X X", iCanId);
  31. else
  32. can[index].strId.sprintf( "%03X", iCanId);
  33.  
  34. for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
  35. {
  36. szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
  37. can[index].strData += szTemp;
  38. }
  39.  
  40. can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
  41.  
  42. numMsgs--;
  43.  
  44. m_nCount++;
  45.  
  46. } // end while ( ulNoMsgs )
  47.  
  48.  
  49. msleep(1);
  50.  
  51. } // end while ( true )
  52.  
  53. }
To copy to clipboard, switch view to plain text mode 

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