Advertisement

C++ / Overloading 'new'

Started by March 28, 2000 04:40 PM
1 comment, last by Timdog 24 years, 5 months ago
Here''s the situation: In order to cut down on memory thrashing, I worte my own memory manager to alloc huge blocks and lock them into physical memory. This is all well and good for structures and data chunks, but now I need to overload my ''new'' operator for several of my classes to improve performance. So my questions are the following: -do I need to explicitly call the constructor for each class in the overloaded new function? -If I have multiple constructors for a single class, do I need to overload new for every single one? -Do I need to explicitly handle inheritance? The Timdog
Simple answer... no to all of the above. Don''t forget to override the delete operator too. In case your curious the constructor gets called after the call to new and the destructor gets called before the call to delete.

Torval

Advertisement
Just to let you know, if you''re doing this via VirtualLock() win32 API, on Win95/98 VirtualLock() is a stub that always succeeds. You can''t lock the memory that way.

If you''re using some other technique that does work, I''d be interested in knowing what it is.

This topic is closed to new replies.

Advertisement