Re: ustring memory leak
- From: Chris Vine <chris cvine freeserve co uk>
- To: Fabian Jacquet <fabian jacquet gmail com>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: ustring memory leak
- Date: Thu, 1 Apr 2010 16:39:14 +0100
On Thu, 1 Apr 2010 16:21:14 +0100
Chris Vine <chris cvine freeserve co uk> wrote:
> On Thu, 1 Apr 2010 13:41:53 +0200
> Fabian Jacquet <fabian jacquet gmail com> wrote:
> > If I replace Glib::ustring by std::string, I don't have the memory
> > leak.
>
> Even if you include the call to Glib::thread_init() when you only use
> std::string?
>
> If so it must be related to a call to g_utf8_collate(): the
> constructor Glib::ustring taking a string literal just calls the
> constructor of std::string, so that can't be it, but the comparison
> operator calls Glib::ustring::compare(), which calls g_utf8_collate().
Or if we are being entirely rigorous about it, just possibly when you
construct a std::string object your compiler is dispensing with the
copy constructor (which will be inline), as it is entitled but not
required to do, but does not do this when constructing a Glib::ustring
object (the constructor for which is not inline); and the copy
constructor of std::string, called by the copy constructor of
Glib::ustring, is leaking.
This seems most unlikely but you could test for it by directly
initialising the string (which in my opinion is better style anyway).
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]