Overloading new and delete

Hi there ,
Overloading new and delete usually involves assigning memory using malloc(size) and deallocating using free() (in cstdlib library). However , I cannot find any difference during the execution. Is there any way to actually see the difference between the program before and after overloading new and delete ?
closed account (zb0S216C)
Do not overload the global "new", or "delete." Most, if not all, standard containers rely on the global memory operators. Overloading these will cause operator resolution errors.

As for measuring the difference, it's difficult to say, because "difference" is a general term. Do you mean speed difference? algorithmic difference?

Wazzak
Last edited on
Speed difference
Do we have some benchmarking software for that ? or something else ?
closed account (zb0S216C)
A "profiler" is what you want, then. A profiler is a piece of software that detects the amount of memory, and CPU usage a program uses, as well as identifying bottlenecks.

Windows Profiler: http://www.codersnotes.com/sleepy/
Unix Profiler: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html#SEC2
Linux Profiler: http://www.rotateright.com/

Wazzak
Last edited on
What kind of speed difference are you expecting Raman? It's done in game development, because dynamic allocation times are too unpredictable, but they need to run AI, a physics simulation, process user input, decompress audio, and render frames with textures and shading at 60fps. Unless you're doing something like that, you're not going to get a speed difference that can be seen without a high-resolution timer.

Also, I think you have the wrong idea about how it works - intercepted calls to new and delete aren't redirected to malloc() and free() - they're no faster. Instead, all the memory needed is allocated upfront by a custom allocator, and calls to new and delete are redirected there.
Topic archived. No new replies allowed.