Re: memory leak
- From: Trigve Siver <trigves yahoo com>
- To: gtkmm-list gnome org
- Subject: Re: memory leak
- Date: Tue, 28 Aug 2007 05:35:52 -0700 (PDT)
>> -
>> 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
I think u mean
Glib::Error::register_cleanup();
Glib::wrap_register_cleanup();
int main(int argc, char *argv[])
{
try
{
Gtk::Main kit(argc, argv);
// ...
}
catch(std::exception const & e)
{
std::cout << e.what() << std::endl;
}
// Additional cleanup
Glib::Error::register_cleanup();
Glib::wrap_register_cleanup();
return 0;
}
Trigve
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]