On Wed, 27 Apr 2005, Christian Biesinger wrote:
Damien O'Brien wrote:
nsIDOMWindow *wind = NULL; wwatch->GetActiveWindow(&wind);

FWIW, you are leaking the window here.

Can I ask one other question - you say above that I'm leaking the window in this piece of code - do you mean leaking memory? If so is the right thing to do to use something like nsMemory::Free to clean this up once I'm done using this pointer?


Yes, it's a memory leak. The right thing is to NS_RELEASE the pointer when you're done with it; even better would be using nsCOMPtr:

 nsCOMPtr<nsIDOMWindow> wind;
 wwatch->GetActiveWindow(getter_AddRefs(wind));

There is a nsCOMPtr manual: http://www.mozilla.org/projects/xpcom/nsCOMPtr.html

(My code must be very leaky. :(  I guess I thought that
QueryInterface was just recasting an existing object.)
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to