I have timer to emit signal to trigger sendMessage every 30 millisecond. after hours , i got heap corruptions

it said
Windows has triggered a breakpoint in matx_migrate.exe.

This may be due to a corruption of the heap, and indicates a bug in
matx_migrate.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information

Qt Code:
  1. void ClientThread::sendMessage(){
  2. #ifdef _DEBUG
  3. qWarning("sendMessage %d\n", QThread::currentThreadId());
  4. #endif
  5. numOfMsg++;
  6. if(numOfMsg>CHECK_PERIOD){
  7. sendCheckMessage();
  8. numOfMsg=0;
  9. }
  10. QList<QByteArray> dataToSend= cannonPtr->getDataToSend();
  11. if(!dataToSend.isEmpty()){
  12. QByteArray data;
  13. QDataStream out( &data, QIODevice::ReadWrite );
  14. out.setVersion(QDataStream::Qt_4_4);
  15. out << (quint16)0;//reserve for size
  16. out << (quint16)dataToSend.count();
  17. for(int i=0; i<dataToSend.count(); i++){
  18.  
  19. data.append(dataToSend[i]);
  20. //out<<dataToSend[i];
  21.  
  22. }
  23. out.device()->seek(0);
  24. out<< (quint16)(data.size() - sizeof(quint16));
  25. #ifdef _DEBUG
  26. quint16 size;
  27. quint16 num;
  28. quint16 kind;
  29. qint32 frame;
  30. qint32 id;
  31. qint32 x;
  32. qint32 y;
  33. bool dead;
  34. QTime time;
  35. out.device()->seek(0);
  36. out>>size>>num>>kind>>frame>>id>>x>>y>>dead>>time;
  37. qWarning()<<"size: "<<size<<"num: "<<num<<"frame: "<<frame;
  38. #endif
  39. socketPrt->write(data);
  40. socketPrt->waitForBytesWritten();
  41.  
  42. dataToSend.clear();
  43. }
  44. }
To copy to clipboard, switch view to plain text mode 


any comments thanks very much