Memory leak
-
I met a problem relating to use CArray in MFC. CArray m_pArr; CMyClass is very simple Class CMyClass { CString m_szName; CString m_szId; long m_i4Age; } allocate memory: for (int i=0;i<1000;i++) { m_Arr.Add(new CMyClass); } destroy memory for (int i = 0;i
-
I met a problem relating to use CArray in MFC. CArray m_pArr; CMyClass is very simple Class CMyClass { CString m_szName; CString m_szId; long m_i4Age; } allocate memory: for (int i=0;i<1000;i++) { m_Arr.Add(new CMyClass); } destroy memory for (int i = 0;i
I'm not familiar with CArray ( I use C++ containers ), but I don't see any problem with this. It would be easier to read your code if you checked 'Do not treat <'s as HTML tags' so it was all visiable though. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
-
I met a problem relating to use CArray in MFC. CArray m_pArr; CMyClass is very simple Class CMyClass { CString m_szName; CString m_szId; long m_i4Age; } allocate memory: for (int i=0;i<1000;i++) { m_Arr.Add(new CMyClass); } destroy memory for (int i = 0;i
lvantin wrote: CArray m_pArr; Correct Usage off CArray class is something like this, Ok let take example of your scenario only
Class CMyClass
{
CString m_szName;
CString m_szId;
long m_i4Age;
}then you declare CArray something like this
CArray<CMyClass,CMyClass&> m_pArr;
[Vote One Here, Complete my Survey....] Alok Gupta
visit me at http://www.thisisalok.tk "I Think Believe this Will Help" -
I met a problem relating to use CArray in MFC. CArray m_pArr; CMyClass is very simple Class CMyClass { CString m_szName; CString m_szId; long m_i4Age; } allocate memory: for (int i=0;i<1000;i++) { m_Arr.Add(new CMyClass); } destroy memory for (int i = 0;i
It seems okay to me. Did you use a profiler to measure, or are you using Task Manager? If it is the latter, there is a good probability that the C++ Runtime Environment is not releasing the memory immediately to the OS. That is perfectly OK. BTW, you don't really need to check if p is not NULL before deleting it, delete(p) itself handles the case where p is NULL. And setting p to NULL has no effect too. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
I met a problem relating to use CArray in MFC. CArray m_pArr; CMyClass is very simple Class CMyClass { CString m_szName; CString m_szId; long m_i4Age; } allocate memory: for (int i=0;i<1000;i++) { m_Arr.Add(new CMyClass); } destroy memory for (int i = 0;i
lvantin wrote: 2. In release mode, leak!!! memory is allocates for application never decrease... How are you confirming this?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
lvantin wrote: 2. In release mode, leak!!! memory is allocates for application never decrease... How are you confirming this?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
I used Performance monitor, a tool is supported by Windows, to investigate this. Private Bytes of the application always increases when i used that code to allocate memory and never descreases when release it.
lvantin wrote: Private Bytes of the application always increases when i used that code to allocate memory and never descreases when release it. Which is perfectly normal.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow