创建了一个BIN文件a.bin,将原先的一个b.BIN文件内容拷贝到buffer 中,再拷贝到a.bin中,然后再将a.bin文件在Edit(m_BinShow)控件中显示,当创建的文件b.BIN比较大时(即m_UintFlash较大),
CPU的占用率达到97%,造成系统死机,请问各位高手大虾怎样解决?
谢谢!!BYTE writeBuf[65536];
BYTE buffer[65536];for(UINT i = 0; i < 65536; i++)
{
   writeBuf[i] = 0;
}UINT m_UintFlash = 32;
UINT m_filelength =2048;CFile outfile;
outfile.Open(a.BIN,  CFile::modeCreate | CFile::modeReadWrite |   
                          CFile::typeBinary, NULL );outfile.WriteHuge(buffer, m_filelength);

UINT m_l;
m_l = m_UintFlash * 1024 - m_filelength;outfile.SeekToEnd();

outfile.WriteHuge(writeBuf, m_l - 2);outfile.Close(); 
         
CFile newfile;
newfile.Open(a.BIN, CFile::modeRead | CFile::typeBinary, NULL);

m_filelength = newfile.GetLength();newfile.ReadHuge(buffer, m_filelength);CString str;
UINT count = 0;

str.Format("%08X",count);
m_BinShow += str +":";
for(UINT i= 0; i < m_filelength; i++)
{
   str.Format("%02X",buffer[i]);
   m_BinShow += str + " ";
   count++;
   m_ProGress.SetPos(i);

   if(count == 16) //控制换行
   {
      m_BinShow +="\r\n";
      str.Format("%08X",i+1);
      m_BinShow +=str + ":";
      count = 0;
      UpdateData(FALSE);
    }}
newfile.Close();

解决方案 »

  1.   

    Edit控件显示内容有限制,当突破64K时需做另外的处理!GOOD LUCK
      

  2.   

    Edit所显示文本数量有限制,好像是1024B吧(记不清了),建议用RichEdit试试。
      

  3.   

    你把edit控件换成richedit控件试试
      

  4.   

    不要用循环来清内存,人家有清内存的函数你怎么不用呢??
    memset(buff,0,sizeof(buff));
      

  5.   

    1.是程序这样还是文章这样?(两个都打开a.Bin文件)
    outfile.Open(a.BIN,  CFile::modeCreate | CFile::modeReadWrite |   
    newfile.Open(a.BIN, CFile::modeRead | CFile::typeBinary, NULL);
    2.使用memset.
    3.建立一个大小为len,内容全为0的文件使用outfile.SetLength(len);
    4.对于这种将读文件的进度显示到进度条上的程序,如果不想为读文件
    单独开一个线程,那就在for()内加一个Sleep()吧!将一部分时间空出
    给CPU.
      

  6.   

    你的程序一定很慢,问题在 CString str;后面的语句。str 未指定大小,浪费内存。
      

  7.   

    就是edit控件限制大小的问题
    建议一开始不要将所有内容写入
    等到用户翻页到某页时再从文件读该页并显示