venom00 | 1 May 03:14 2011

RE: Memory LyXs

> I've looked briefly at this one before, and I find it confusing.  It
> looks as if it is saying that we are leaking the docstring 
> word itself,
> i.e., that it's not being cleaned up, but why would that be?

Mmmh, I find it pretty simple: we have some elements added to a set but never removed.

> Other question: Doesn't
> ==22649== 47,920 bytes in 960 blocks are indirectly lost in 
> loss record
> 920 of 921
> 
> say that there are just 47K bytes, which are scattered through 960
> blocks, that have been lost? That would make more sense to me, since
> they'd average about 50 bytes a piece, which looks about the size of a
> string. If so, the leak isn't that terrible.

Well, they're 47 kB for a short session, but in a session of several days/week... If I understand it
correctly, we leak every single word is inserted in a paragraph, as we never delete them.
When valgrind says that something is "indirectly lost" means that you have, for instance, a tree and you
deleted the root but not all the children [1]. It looks like our sitaution.

> Anyway, the obvious thing to do here is uncomment the code you
> identified and see if that helps.

I'll try that. Maybe we could add a bool parameter to WordList::remove to decide if really remove the node or
just ignore it. I'd ask to the author of the code, sts (from svn blame), is he still active?

> The other thing maybe worth trying is something simple like:
> 
(Continue reading)

Richard Heck | 1 May 16:55 2011
Picon
Picon

Re: Memory LyXs

On 04/30/2011 09:14 PM, venom00 wrote:
>> I've looked briefly at this one before, and I find it confusing.  It
>> looks as if it is saying that we are leaking the docstring 
>> word itself,
>> i.e., that it's not being cleaned up, but why would that be?
> Mmmh, I find it pretty simple: we have some elements added to a set but never removed.
I know less about this then I should. (I'm just an amateur.) But: When
we call delete d, doesn't this call the d->words_ destructor? I mean,
you can do:

    if (...) {
        set<int> tmp;
        for (int i = 0; i < 1000; ++i)
            tmp.insert(i);
    }

and there is no memory leak, because all the ints in the set are
destroyed when tmp goes out of scope. Similarly, when we delete the
pimpl, the words_ set should be deleted, and this takes care of
everything in that set. Right?

>> The other thing maybe worth trying is something simple like:
>>
>> Index: src/Paragraph.cpp
>> ===================================================================
>> --- src/Paragraph.cpp (revision 38560)
>> +++ src/Paragraph.cpp (working copy)
>>  <at>  <at>  -3500,12 +3500,11  <at>  <at> 
>>     pos_type from = pos;
>>     locateWord(from, pos, WHOLE_WORD);
(Continue reading)


Gmane