lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix memleak: temporary skyline objects for systems were never delete


From: Reinhold Kainhofer
Subject: Re: Fix memleak: temporary skyline objects for systems were never deleted (issue 4923048)
Date: Wed, 24 Aug 2011 19:47:45 +0200
User-agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; i686; ; )

Am Mittwoch, 24. August 2011, 15:38:21 schrieb Han-Wen Nienhuys:
> On Wed, Aug 24, 2011 at 3:38 AM, David Kastrup <address@hidden> wrote:
> > Skylines are smobs.  The usual way to delete them would be to unprotect
> > them once they have been registered by some garbage-collectable object
> > (or a SCM variable that is being used for accessing them).
> 
> They are simple smobs, though, so this pattern here is not uncommon.
> You could also try to allocate them on the stack.

So, what do you think would be the appropriate fix for this memleak? 
I don't see how I could allocate the skylines on the stack just for the case 
of systems (notice that the "new Skyline" allocations are inside an if!). We 
don't want to allocate a new skyline for all Skyline::distance() calls, just 
for those, where the padding has not been added yet.

OTOH, I don't know anything about how guile is able to handle C++ class 
instances and how to tell it to delete a class instance allocated with new.


However, currently valgrind says the skyline memory is definitely lost:

==28530== 2,040 (24 direct, 2,016 indirect) bytes in 2 blocks are definitely 
lost in loss record 6,104 of 6,263
==28530==    at 0x402641D: operator new(unsigned int) 
(vg_replace_malloc.c:255)
==28530==    by 0x8234A28: Skyline::distance(Skyline const&, double) const 
(skyline.cc:526)
==28530==    by 0x81BCC8F: Page_layout_problem::append_system(System*, Spring 
const&, double, double) (page-layout-problem.cc:496)
==28530==    by 0x81BC37D: 
Page_layout_problem::Page_layout_problem(Paper_book*, scm_unused_struct*, 
scm_unused_struct*, int) (page-layout-problem.cc:411)
==28530==    by 0x81ABCD8: 
Page_breaking::get_page_configuration(scm_unused_struct*, int, int, bool, 
bool) (page-breaking.cc:537)
==28530==    by 0x81AC2B0: Page_breaking::make_pages(std::vector<unsigned int, 
std::allocator<unsigned int> >, scm_unused_struct*) (page-breaking.cc:617)
==28530==    by 0x81A3891: Optimal_page_breaking::solve() (optimal-page-
breaking.cc:211)
==28530==    by 0x81B9ADE: ly_optimal_breaking(scm_unused_struct*) (page-
breaking-scheme.cc:42)
==28530==    by 0x4090F18: scm_dapply (in /usr/lib/libguile.so.17.3.1)


Cheers,
Reinhold

-- 
------------------------------------------------------------------
Reinhold Kainhofer, address@hidden, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]