100分!!!!!!!!!!!!!!!!!超级疑难问题:对sql server 2000插入记录的代码的程序的内存不断增长。

lovememememe 2008-07-12 02:06:31
sql server 2000安装在服务器上,对此数据库操作的程序跑在客户端上,每当有如下代码段时,内存就疯一般的增长也不降下来,怎么回事?怎么解决?


m_pRecordset->AddNew();
m_pRecordset->PutCollect("PlateNum",_variant_t(DB_PlateNum));
m_pRecordset->PutCollect("HaveTime",_variant_t(DB_HaveTime));
m_pRecordset->PutCollect("PlateType",_variant_t(real_DB_PlateType));
m_pRecordset->PutCollect("PlateColor",_variant_t(DB_PlateColor));
m_pRecordset->PutCollect("LaneNum",_variant_t(DB_LineNum));
m_pRecordset->PutCollect("PortNum",_variant_t(real_DB_PortNum));
m_pRecordset->PutCollect("ImgName",_variant_t(DB_ImgName));

m_pRecordset->PutCollect("IsWarning",_variant_t(DB_Iswarning));
m_pRecordset->PutCollect("Ctype",_variant_t(real_DB_Ctype));

CFileException e;
OutputDebugString("debug 1");
if(fwdb.Open(SA_Path_N, CFile::modeRead | CFile::typeBinary, &e)) //打开了一个近景jpg文件
{
int nSize = fwdb.GetLength(); //先得到jpg文件长度
BYTE * pBuffer = new BYTE [nSize]; //按文件的大小在堆上申请一块内存
// BYTE pBuffer[1024*300];
if (fwdb.Read(pBuffer, nSize) > 0 ) //把jpg文件读到pBuffer(堆上申请一块内存)
{ // +----------------------------------------------
VARIANT varBLOB;
SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
if(pBuffer)
{
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = nSize;

psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
for (long i = 0; i < (long)nSize; i++)
SafeArrayPutElement (psa, &i, &pBuffer[i]);

varBLOB.vt = VT_ARRAY | VT_UI1;
varBLOB.parray = psa;

m_pRecordset->GetFields()->GetItem("NImgData")->AppendChunk(varBLOB);//把jpg文件插入到数据库中

OutputDebugString("debug 4");
}

}
if(NULL!=pBuffer)
delete [] pBuffer; //删掉堆上申请的那一块内存
fwdb.Close();
}
...全文
46 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovememememe 2008-07-12
  • 打赏
  • 举报
回复
是客户机上的程序内存增大

22,300

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧