Re: memory leak



> -
> and a lot of leaks:
> ==5048== LEAK SUMMARY:
> ==5048==    definitely lost: 0 bytes in 0 blocks.
> ==5048==      possibly lost: 49,424 bytes in 54 blocks.
> ==5048==    still reachable: 237,710 bytes in 4,803 blocks.
> ==5048==         suppressed: 0 bytes in 0 blocks.
>

(waving hand in the air) There are no leaks here. </bad_starwars_joke>

These aren't really leaks perse, but memory that never gets
deallocated. To prove it to yourself, try something along the
following:

#include <gtkmm.h>

ITERS=1000

int main(int argc, char *argv[]) {
  Gtk::Main kit(argc, argv);

  //Print memory usage.

   for( int i = 0 ; i < ITERS ; i++ )
   {
      Gtk::Label* lbl = new Gtk::Label()
      delete lbl ;
   }

   //Print memory usage

  return 0;
}

The two memory usage numbers should be the same. I can't believe I
don't remember how to get the current memory usage off the top of my
head, but its been awhile since I've done something like this. I
believe there's a system call like 'usage' or some such. Anyway,
google will have the answer for that detail.

Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]