|
-
March 22nd, 2004, 10:47 PM
#1
CObArray with VC.net
Hi guys,
my program meet a memory problem when I used the CObArray.
the code follows,
Class A{
...
CObArray m_ar;
}
Class A::function{
...
for(i = 0,i < size,i++)
{
m_ar.Add((CObject*)(new CRect(r)));
}
..
}
.....
A::~A()
{
for(int i = 0; i < m_ar.GetSize(); i++)
delete (CRect*)m_ar[i];
}
the code compiled and linkered in the VC 6 is ok and the program run normally...it compiled and linkered normally in VC.net but the .exe file generated by VC.net has Unhandled exception at 0x77f9180c in .exe: User breakpoint.
the breakpiont in VC.net
int __cdecl _heapchk (void)
{
...
if (!HeapValidate(_crtheap, 0, NULL))//line 104
{
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
_doserrno = ERROR_CALL_NOT_IMPLEMENTED;
errno = ENOSYS;
}
else
retcode = _HEAPBADNODE;
}
...
}
.exe!_heapchk() Line 104 + 0x10 C
.exe!_CrtCheckMemory() Line 1500 + 0x5 C
.exe!_free_dbg_lk(void * pUserData=0x02018ab8, int nBlockUse=1) Line 1100 + 0x5 C
.exe!_free_dbg(void * pUserData=0x02018ab8, int nBlockUse=1) Line 1070 + 0xd C
.exe!operator delete(void * p=0x02018ab8) Line 365 + 0xb C++
I try the following method to solve the problem but it failed
int size = m_ar.GetSize();
if(size != 0){
CRect* pRect[10000] ;//10000 must biger than the size
for(int i = 0; i < size;i++){
pRect[i] = (CRect*)m_ar[i];
}
m_ar.RemoveAll();
for (i = 0; i < size;i++){
delete pRect[i];
}
VC.net still break in the line delete pRect[i] when i run the .exe
file
i try to only use the code m_ar.RemoveAll();it is ok...but it seems not to delete the pointer allocated by the operator new.
how could i solve the problem in VC.net?
what is the difference of CObArray between VC.net and VC6,or what is the difference of the delete between VC.net and VC6?
thanks in advance
-
March 29th, 2004, 10:44 AM
#2
anyone know about detecting the heap?
how can i monitor allocation of the heap?
I use class1* p = new class1; Is it allocated on the default heap or other heap?
what do the following output of CMemoryState: umpStatistics stand for?
Memory leaked
0 bytes in 0 Free Blocks.
-626 bytes in -13 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
-1212 bytes in -6 Client Blocks.
Largest number used: 178 bytes.
Total allocations: 988 bytes.
Are all the blocks allocatec on the same heap?
what do the negative integer mean?
what does the largest mumber mean?
where can i get the article that introduce allocation on the heap?
thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|