Review Request 110057: Fix mem leaks in kunitconversion
Albert Astals Cid
aacid at kde.org
Wed Apr 17 19:00:46 BST 2013
> On April 16, 2013, 9:35 p.m., Christoph Feck wrote:
> > Thanks for spotting this. If this does not exceed your C++ skills, could you try creating the objects on the stack instead, so they are automatically deleted once out of scope?
>
> Dario Cambié wrote:
> Sorry, I've tried without success :(
>
> Thomas Lübking wrote:
> It's wrong anyway, see Alberts comment.
> Depending on the pointer use, you'll either have to just delete complex in the UnitPrivate (and ensure to init it as NULL) or use some shared data pointer (and delete it with the last unref)
>
> Whether from a stack or heap object, the U macro will create data on the heap, linking pointer or reference which will dangle around when you delete it or drop out of context.
FWIW I had a look at Randa last year at these leaks and as far as I remember they are one time leaks, that is a singleton-like structure will be created at the start of the program and not deleted at the end. Yes it's not great but it will not cause your app to use more memory over time.
- Albert
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/110057/#review31188
-----------------------------------------------------------
On April 16, 2013, 9:31 p.m., Dario Cambié wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/110057/
> -----------------------------------------------------------
>
> (Updated April 16, 2013, 9:31 p.m.)
>
>
> Review request for kdelibs.
>
>
> Description
> -------
>
> Little patch for memory leaks in kunitconversion: functions dynamically created were never deleted.
> Not sure if the patch is correct (C++ is not my language at all) but it seems to "work for me".
>
>
> Diffs
> -----
>
> kunitconversion/angle.cpp 6333925
> kunitconversion/fuel_efficiency.cpp 1914fab
>
> Diff: http://git.reviewboard.kde.org/r/110057/diff/
>
>
> Testing
> -------
>
> Compiles, no more mem leaks according to valgrind.
>
> valgrind before (e.g.):
> ==8754== 8 bytes in 1 blocks are definitely lost in loss record 110 of 644
> ==8754== at 0x4C2AF8E: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==8754== by 0x5A3EE11: Angle::Angle() (angle.cpp:51)
>
> valgrind after:
> no such alert
>
>
> File Attachments
> ----------------
>
>
> http://git.reviewboard.kde.org/media/uploaded/files/2013/04/16/0001-Fix-minor-mem-leaks-in-kunitconversion-angle-and-fue.patch
>
>
> Thanks,
>
> Dario Cambié
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20130417/1af19c20/attachment.htm>
More information about the kde-core-devel
mailing list