Advertisement

Detecting Memory Leaks

Started by November 19, 2000 05:32 AM
0 comments, last by Ksero 24 years, 1 month ago
Hi everyone... I''ve been trying to implement a memory leak tutorial over at flipcode... The idea is basically to override new and delete like this:
  
#ifdef _DEBUG
inline void * __cdecl operator new(unsigned int size,
		const char *file, int line)
{
	void *ptr = (void *)malloc(size);
	AddTrack((DWORD)ptr, size, file, line);
	return(ptr);
};
inline void __cdecl operator delete(void *p)
{
	RemoveTrack((DWORD)p);
	free(p);
};
#endif
  
But I''ve thought of a few problems... 1) The constructor isn''t called in the overriden new-operator...? 2) He says that "In addition to these, you may also need to override the new[] and delete[] operators as well. They are the same so I just left them out to save space". But they aren''t the same! So this Memory-Leak detector doesn''t detect mistakes like using delete instead of delete[]? How do you detect memory leaks (preferably in DJGPP)? Thanks for your time! /Ksero
Check out the memory debug class at glVelocity (TCS''s site) in the code archive.

Regards,
Jumpster
Regards,JumpsterSemper Fi

This topic is closed to new replies.

Advertisement