RE: [GD-Windows] memory leak?
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2002-11-07 18:31:11
|
> [A] Best guess: You are doing "new" and "delete" > on a regular "struct", instead of a "class". > This may simply allocate raw bytes with the > same size as your structure. This means that Not true. #include <stdio.h> struct bar { bar() { puts("bar::bar()"); } ~bar() { puts("bar::~bar()"); } }; struct foo { bar b; }; int main() { foo * f = new foo[ 1 ]; delete[] f; return 0; } This prints the appropriate constructor/destructor. In fact, the auto-generated assignment operator will also do the right thing. However, if you implement your own assignment operator, it will have to do all that manually. > [B] Some kind of DLL page(s) just wasn't (weren't) > added to your process until you touched the > "new" and "delete" operators (implemented as Possible. > [C] The C run-time library malloc() and free() > are "lazy" when it comes to returning memory > pages back to the OS -- for efficiency. This is usually the case. Similarly, the OS may be lazy about returning pages from your general pool, even if you have marked them as uninteresting. Hence, the Task Manager's "memory" display is often a little bit misleading. A good memory tracking subsystem is important to any decent-size project. Cheers, / h+ |