Java memory leaks (转)ITeye - 众发娱乐

Java memory leaks (转)ITeye

2019-01-13 14:12:51 | 作者: 千风 | 标签: 获取,对话框,子项 | 浏览: 2131

内存走漏:Detected memory leaks //对话框类,调用CSCItemCount类rnvoid CSCCountDlg::OnOK() //核算功用rnrn CSCItemCount scItemCount;rn CString strValue;rn double dStandCost(0);rnrn tryrn rnrn m_pPDMItem = new CPDMObject;rn m_pPDMItem- m_pClass = pItemCls;rn m_pPDMItem- InitColumnContentList();rn m_pPDMItem- m_nObjectID = m_nObjectID;rnrn rn [color=#FF0000]if( !scItemCount.LoadSubItem( rnrnm_pdmSel.m_nObjectID,m_pPDMItem,pBomCls,perdef1.m_lstFO,m_pChGlobarVar ) )rn rn throw 101;rn rn [/color]rn dStandCost = scItemCount.m_dStandCost;rnrn rn [color=#FF0000]if( NULL != m_pPDMItem )rn delete m_pPDMItem;[/color] rn rn catch( ... )rn rn rn if( NULL != m_pPDMItem )rn delete m_pPDMItem;rn return ;rn rnrnrn m_dStandCost = dStandCost;rn UpdateData( false );rnrnrn//CSCItemCount 类,与对话框类不在同一DLL中rnrnBOOL CSCItemCount::LoadSubItem( UINT nObjectID,CPDMObject *pItemObj, CPDMClass *pBomCls, rn COptionList lstFo,CCheckGlobalVar rnrn*pChGlobarVar )rnrn COleDateTime tmCurSys;rn CString strProduct, strTime;rn CPDMResourceMgr mgrResource( _T( pdmcore.dll ) );rn CAConnect myConnect;rn CString strCount;rnrn strProduct= _T( rn //1) 获取服务器当时时刻rn if( !DLLGetSysCurDate( strTime, tmCurSys ) )rn tmCurSys = COleDateTime::GetCurrentTime();rnrn //2) 衔接数据库rn if ( !CCommFun::ConnectDB( myConnect, m_strServer, m_strDBName, m_strDBUser, m_strDBPwd ) )rn return false;rnrn _CONNECT_PDMSERVER_RETURN()rn m_pItemObj = pItemObj;rn m_pItemObj- m_fQuantityOld = m_pItemObj- m_fQuantity;rnrn [color=#FF0000]//3) BOM打开rn if( !this- LoadChildItem( myConnect,session, pItemObj, pItemObj- m_pClass ,pBomCls, m_lstItem, rnrnlstFo, tmCurSys, strProduct , pChGlobarVar ) )rn return false;[/color]rn //核算,依据m_lstItem记载的内容从数据库读取内容rn m_lstItem.RemoveAll( );rn rn return true;rnrnrnrnBOOL CSCItemCount::LoadChildItem ( CAConnect myConnect,CSession session,CPDMObject *pItemObj, rnCPDMClass *pItemCls,CPDMClass *pBomCls, CObList lstItem, COptionList lstFo, COleDateTime tmCurSys, rnCString strProduct,CCheckGlobalVar *pChGlobarVar )rnrn CPDMObjectList::Position pos;rn CSCItemCount *pSubItem = NULL;rn CString strMPType,strControl, strStock;rn CFieldList lstField;rn BOOL bFolder = false;rn CItemOperate ItemOperate;rn CString strErr;rn double dStandCost(0);rn double dCost(0); rnrn //1) 获取指定物料的指定信息rn ItemOperate.m_pGlobalVar = pChGlobarVar;rn if( !ItemOperate.GetItemInfo( session, pItemObj- m_nObjectID, pItemObj- m_pClass- m_strTabName, rnrnstrStock, strControl, strMPType, strErr ) )rn rn AfxMessageBox( strErr );rn return false;rn rn //2) 记载BOM打开所得的一切物料目标rn this- m_dSCost = 0;rn lstItem.AddTail( this );rnrn //3) NN?(是否操控-是否入库)rn if( (strControl.CompareNoCase(_T( N )) ==0) (strStock.CompareNoCase(_T( N )) == 0 ) )rn rn //3.1) 获取ITEM的子项列表rn GetSubItemPDMObjList( session, pItemObj, pBomCls, strProduct, tmCurSys, lstFo, lstField rnrn);rn //3.2) ITEM有子项,逐条获取其子项的子项,[color=#FF0000]m_lstSubPDMObj将在对话框内delete pPDMItem时析构 [/color]rn if( pItemObj- m_lstSubPDMObj.NumItems() != 0 )rn rn for( pItemObj- m_lstSubPDMObj.BeginScan( pos ); pos ; pos++ )rn rn if( NULL == (*pos ) )rn continue;rn pSubItem = new CSCItemCount;rn pSubItem- m_pItemObj = (*pos );rn pSubItem- m_pParItem = pItemObj;rn pSubItem- m_pParCount = this;rn pSubItem- m_pItemObj- m_fQuantityOld = (pItemObj- m_fQuantityOld) * rnrn((*pos)- m_fQuantity);rn this- m_lstSub.AddTail( pSubItem );rnrn if( !pSubItem- LoadChildItem( myConnect,session, (*pos ), pItemCls, rnrnpBomCls, lstItem, lstFo, tmCurSys, strProduct,pChGlobarVar ) )rn return false;rn rn rn rnrn return true;rnrnrn//析构函数rnCSCItemCount::~CSCItemCount()rnrn m_anID.RemoveAll();rn DetachSubList();rnrnrnvoid CSCItemCount::DetachSubList()rnrn CSCItemCount *pItem =NULL;rn POSITION pos;rnrn for ( pos = m_lstSub.GetTailPosition(); pos; )rn rn pItem = (CSCItemCount*)m_lstSub.GetPrev( pos );rn if ( NULL != pItem )rn rn delete pItem;rn pItem = NULL;rn rn rnrn m_lstSub.RemoveAll();rnrn如上进程,我以为一切我new出的目标最终都delete了,但为什么程序正常完毕后,会有很多的提示如下:rnrnDetected memory leaks!rnDumping objects - rn24158 normal block at 0x0B3D1EC8, 20 bytes long.rn Data: = m \ = 00 00 00 00 F8 1D 3D 0B C4 6D F6 08 5C 1E 3D 0B rnstrcore.cpp(118) : 24157 normal block at 0x0B3D1E50, 45 bytes long.rn Data: 2930 01 00 00 00 06 00 00 00 20 00 00 00 32 39 33 30 rn24156 normal block at 0x0B3D1DF8, 20 bytes long.rn Data: = ( = g = C8 1E 3D 0B 28 1D 3D 0B 8C 67 F6 08 8C 1D 3D 0B rnstrcore.cpp(118) : 24155 normal block at 0x0B3D1D80, 45 bytes long.rn Data: 01 00 00 00 00 00 00 00 20 00 00 00 00 20 20 20 rn24154 normal block at 0x0B3D1D28, 20 bytes long.rn Data: = X = Ta = F8 1D 3D 0B 58 1C 3D 0B 54 61 F6 08 BC 1C 3D 0B rnstrcore.cpp(118) : 24153 normal block at 0x0B3D1CB0, 45 bytes long.rn Data: 01 00 00 00 00 00 00 00 20 00 00 00 00 20 20 20 rn请高手指导rn

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表众发娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章