|
-
July 25th, 2014, 05:56 PM
#1
Invoke AfxThrowMemoryException cause "Access Violation"
I want to override the operator new in a class, as follows:
class CMyclass
{
public:
void* operator new(size_t);
void operator delete(void*);
};
void* CMyclass: perator new(size_t size)
{
void *p;
p = MemoryManager.Alloc(size); // Using customized memory manager to allocate buffer
if (NULL == p)
AfxThrowMemoryException();
}
However, in debug version, whenever MemoryManager.Alloc(size) returns NULL, which means alloation fails, the AfxThrowMemoryException will cause the following exception:
Access violation reading location 0x#######
How to fix the problem.
Tags for this Thread
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
|