我做了个服务端程序 ,  需要不断的写数据库。  在 一期上线的时候 就不断出现  “This application has requested the Runtime to terminate it in an unusual way.Please contact the application's support team for more information”。。数据库占用内存很大。 当时内存是 2G的。。后来叫人帮我优化了一下数据库。 又加了个4G 的内存。 跑了几个月都没问题。
    这次又做二期,,,,添加了几个功能 , 又加了两个数据库.. 上线的时候又出现同样的问题了。  现在是上线初期,我加了的两个数据库。现在还没有用。 开始 我怀疑是内存泄漏。。但观察几天后内存都没有增长。。 所以我现在还是怀疑是数据库的问题。。 但我不知道怎么解决。。    希望有经验的能帮帮忙。很急。

解决方案 »

  1.   

    szBuf.Format("update RiskCtrl set log_on_time='%s' where user_id_buyer = '%s'",strLogOnTime,user_id_buyer);
    m_pConn->Execute((_bstr_t)szBuf,NULL,adCmdText);我是这样写的数据库
      

  2.   

    应该不会啊,是不是程序其他地方存在问题。再一个你是不是也打开了一个记录集呢?我看你的m_pConn好象是一个长连接,如果写数据库不是很频繁可以用短连接,用的时候临时连。或者到一定的时间以后先把m_pConn关闭一下,然后再重新连一下。
      

  3.   

    还有一个问题就你在Execute的时候一定要try catch,如果里面的数据不对时有时出出异常。如果捕获到异常就先把m_pConn关掉再打开。
      

  4.   

    谢谢几位的帮助,我 改了一下程序 , 你看看这样可以不 try
    {
    szBuf.Format("update RiskCtrl set amount=amount+%s where type = %s and user_id_buyer = '%s'",sAmount,sType,sID);
    m_pConn->Execute((_bstr_t)szBuf,NULL,adCmdText);
    }
    catch(_com_error e) 

    string strError = e.Description();
    printf("write DB error: %s\n", strError.c_str());
    LOG( LOG_ERROR_DATA ,"write DB error: %s\n", strError.c_str());