User forums > General (but related to Code::Blocks)
Is this a memory leak?
Pecan:
I know this is probably a stupid question, but is wxString
freed in the following example? Or is there a leak.
Something like this happend to me during the recent
settings scheme revamp.
--- Code: ---class Aclass
{
wxString* MyStringPtr;
~Aclass(){}
}
Aclass::Aclass()
{
MyStringPtr = new wxString;
}
--- End code ---
This is worrying me.
Thanks
pecan
280Z28:
It's not freed.
rickg22:
Hint: Pointers to objects (wxString* m_pString) should always be allocated and deallocated manually on the constructor and destructor.
Direct objects (wxString m_String) are handled automatically.
killerbot:
a leak it is !
@Rick, not everything allocated by the user has to be freed by the user, especially with wxWidgets and menus, the ownership is tranfered in those cases.
So it's good to realize when ownership is transfered.
I for one, sureley doesn't know all the transfers within wx. :(
thomas:
--- Quote from: killerbot on January 24, 2006, 01:14:20 am ---I for one, sureley doesn't know all the transfers within wx. :(
--- End quote ---
If you give it away, you don't own it any more. That's a 99% good rule (with very very few exceptions).
Navigation
[0] Message Index
[#] Next page
Go to full version