1.dev enviroment:VC++ 6.0 2.build program in 'release' 3.store 1000000 simple objects in CArray 4.run the program without debug After running the code , it's about 85M memory cannot be release on my computer. Can anyone explain and solve the problem for me? Thanks. BTW:Because of the legency project code,my dev IDE is not allowed to update to the latest VisualStudio. So i have to solve the problem in VC 6.0 IDE. #include "afxtempl.h" long int g_cCount = 0; long int g_dCount = 0; class CMyTest { public: CString m_str; CMyTest() { m_str = "test string"; g_cCount++; } ~CMyTest() { g_dCount++; } }; typedef CArray<CMyTest,CMyTest&> CArrayTest; void Test() { g_cCount = 0; g_dCount = 0; CArrayTest testArray; int count = 1000000; for(int i =0;i < count; i++ ) { CMyTest testObj; testObj.m_str = "test string"; testArray.Add(testObj); } testArray.RemoveAll(); testArray.FreeExtra(); } void CTestMemDlg::OnOK() { Test(); CString strInfo; strInfo.Format("Object construction: %d destruction: %d \r\n",g_cCount,g_dCount); AfxMessageBox("finish\r\n"+strInfo); }
lostangels
Posts
-
Memory leak in VC++ 6.0 when store lots of objects in CArray,please help me! -
CString problem in visual C++ 2005i do agree with Sarath. when you change the charset in the project property sheet from "Use Unicode Libraries" to "Use MBCS Libraries",the compile problem with CString will disappear at once.
-
how to get all the xml content using MSXML?aaaa i am using VC 6 to read and write xml file content with MSXML component. but i cannot find a way to get all the xml content like the property "innerxml" in .NET class. can anyone tell me how to implement this? thanks a lot
-
can i export interface from a exe file?i want to write an exe program file,it can run stand alone,and also i want to make it possible that other programs can call functions exposed by the exe,just like call functions exposed by a dll file. is that possible? thanks for any reply.
-
how can i forbid anyone else to change the time of the computer?i have a computer that used by several people and i don't want anybody else to change the date and time of the computer, how can i do this through VC++? thx.
-
how to implement hotfix function?usually,when main exe is running,the dlls it loaded cannot be replaced. i want to replace the loaded dll without kill the main exe. the process of replace the dll module without stop the main exe is called "make hotfix"
-
how to implement hotfix function?:confused: in my program,the main exe runs with several dll modules, and i want to implement the function of replacing one of the dll files when the main exe is running? can anyone give me some advice? thanks a lot
-
MFC SDI Program crashed when press F12I create a SDI program using Visual C++ 6.0(without any service pack installed),without adding any source code by myself ,i start the program in debug mode,then press F12,so the crash happens.But if i run the program not in debug mode and press F12,nothing will happen. Can anybody tell me why this would happened and how can i to resolve it? Thanks a lot.
-
Scrollbar in CFormView does not work,why?just crreating a new SDI project with VC++ wizard, choose CFormView as the base view class, then switch to the resource editor, place a CListBox control on the formview, and make sure to enlarge the formview design size so that a scrollbar can appear later, then ,build it and run, though the scrollbar is visible, but i just can't let it scroll with my middle mouse wheel, can anybody tell me what's the reason?? thanks a lot. lostangels@163.com
-
Scrollbar in CFormView does not work,why?just crreating a new SDI project with VC++ wizard, choose CFormView as the base view class, then switch to the resource editor, place a CListBox control on the formview, and make sure to enlarge the formview design size so that a scrollbar can appear later, then ,build it and run, though the scrollbar is visible, but i just can't let it scroll with my middle mouse wheel, can anybody tell me what's the reason?? thanks a lot.