Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Memory Management Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Effin Goose

July 17, 1999, 02:45 AM

Hi,

I am currently trying to program a simple memory management scheme in which it can tell me whether all memory that has been allocated, has been deallocated. This is relatively simple for memory allocation with malloc (simply by writing a myMalloc function), but i was wondering if such a thing can be done. I thought perhaps by overloading the new operator, but this would have to be done for every class that i wanted to keep track of. Does anyone know of another way of checking whether memory has been deallocated or have any information on overloading the new operator?

thanks for your time..


 
Blah

July 17, 1999, 07:31 PM

Overloading the new and delete operators is a good way to go. Just put these two functions
somewhere in your code:

void *operator new( size_t size );
void operator delete( void *address );

The variable names 'size' and 'address' can be something different, that's just what I used
for this example. Also, there is another form of delete that isn't used very often - see the
help files in your compiler for that one.

You don't have to overload new and delete for every class, because the above functions are
global, so any class that doesn't already have overloaded new and delete operators will use
the above functions. That's how I understand it at least, from reading the docs in Visual
C++'s online help. Hope that helps you out

----Blah








Effin Goose wrote:
>>Hi,
>>
>>I am currently trying to program a simple memory management scheme in which it can tell me whether all memory that has been allocated, has been deallocated. This is relatively simple for memory allocation with malloc (simply by writing a myMalloc function), but i was wondering if such a thing can be done. I thought perhaps by overloading the new operator, but this would have to be done for every class that i wanted to keep track of. Does anyone know of another way of checking whether memory has been deallocated or have any information on overloading the new operator?
>>
>>thanks for your time..
>>
>>

 
Effin Goose

July 17, 1999, 09:29 PM

Thanks for that, that was exactly the kind of thing i was looking for...


 
MemGuy

July 26, 1999, 11:14 PM

Hi.
First of all why do people use malloc? or C instead of C++?
Anyway I'm just wondering if we still can use EMS BIOS in order to get more than 1 MB. After the protected mode revolution, it seems that everything has been taken care of by the compiler(just like garbage collection is automatic in JAVA). In short we lost some control over memory management.(I think) Please comment on today's Memory Management.



 
This thread contains 4 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.